Class ObjectPooler
Simulates object instantiation and destruction by recycling them.
Inheritance
Object
Component
Behaviour
MonoBehaviour
ObjectPooler
Inherited Members
Namespace: GGL.Pooling
Assembly: GGL.dll
Syntax
[AddComponentMenu("GG-Library/Singletons/Object Pooler")]
[HelpURL("https://ggl.yoannhaffner.com/articles/gameobject.html#optimisation")]
public class ObjectPooler : SingletonBehaviour<ObjectPooler>
Methods
| Edit this page View SourceClear()
Clear the cache of registered objects.
Declaration
public static void Clear()
Create(string, params Type[])
Simulates a gameobject creation by recycling if available (real new otherwise).
Declaration
public static GameObject Create(string name, params Type[] components)
Parameters
Type | Name | Description |
---|---|---|
string | name | Simulates object instantiation and destruction by recycling them. |
Type[] | components | Simulates object instantiation and destruction by recycling them. |
Returns
Type | Description |
---|---|
GameObject |
Remarks
DO NOT RENAME THE INSTANCIATED OBJECT PLEASE.
Destroy(GameObject)
Simulate the destruction of a gameobject by recycling him
Declaration
public static void Destroy(GameObject poolObject)
Parameters
Type | Name | Description |
---|---|---|
GameObject | poolObject |
Destroy<T>(T)
Simulate the destruction of an object by recycling him.
Declaration
public static void Destroy<T>(T poolObject) where T : Component
Parameters
Type | Name | Description |
---|---|---|
T | poolObject |
Type Parameters
Name | Description |
---|---|
T | Simulates object instantiation and destruction by recycling them. |
Instantiate(GameObject, Transform)
Simulates an object instantiation by recycling if available (real instantiate otherwise).
Declaration
public static GameObject Instantiate(GameObject prefab, Transform parent = null)
Parameters
Type | Name | Description |
---|---|---|
GameObject | prefab | |
Transform | parent |
Returns
Type | Description |
---|---|
GameObject |
Remarks
DO NOT RENAME THE INSTANCIATED OBJECT PLEASE.
Instantiate<T>(T, Transform)
Simulates an object instantiation by recycling if available (real instantiate otherwise).
Declaration
public static T Instantiate<T>(T prefab, Transform parent = null) where T : Component
Parameters
Type | Name | Description |
---|---|---|
T | prefab | |
Transform | parent |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T | Simulates object instantiation and destruction by recycling them. |