Object Pool Extensions
Create Pool
This method creates a pool of GameObjects based on a specified prefab and pool size, initializing each instance as inactive.
Resize Pool
This method adjusts the size of an existing pool. If the pool has fewer objects than the new size, it adds more objects. If the pool has more than the new size, it removes the extras.
Clear Pool
This method clears the pool by destroying all instances and emptying the list.
Get Object
This method retrieves the first inactive object from the pool and activates it for use. If no inactive objects are available, it creates a new one, adds it to the pool, and returns it.
Return Object
This method returns an object back to the pool, resetting its transform and deactivating it so it can be reused later.
Last updated