You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This asset will be used to get and return objects from and to the pool providing reusability and automatic creation of the object if the pool is empty.
4
+
You can use this asset for reusability of your objects.
5
+
6
+
7
+
-------- ObjectPool<T>
8
+
9
+
ObjectPool(string a_strObjectType, int a_iStartSize = 0)
10
+
11
+
where a_strObjectType is the typeof(T)
12
+
a_iStartSize is the size of the pooled objects
13
+
14
+
Pool.getObject() returns a object of type T from the pool and sets it to active.
15
+
Pool.returnToPool(T obj) to return the object to the pool and deactivates the object.
16
+
Pool.returnAll() to return all objects back into the pool and deactivates all the object.
17
+
18
+
-------- IReusable
19
+
20
+
The reusable object of type T should be derived from IReusable
21
+
-- T.onRetrievedFromPool()
22
+
will be called when the object is retrieved from the pool.
23
+
-- T.onReturnedToPool()
24
+
will be called when the object is returned to the pool.
25
+
26
+
27
+
28
+
-------- MonoObjectPool<T>
29
+
To use an object pool for MonoBehaviour objects, use
30
+
31
+
MonoObjectPool<T>(T a_Prefab, GameObject a_Parent, int a_iStartSize = 0)
32
+
33
+
where T is the prefab to manage
34
+
a_Parent is the gameobject which will act as the parent gameobject of the instantiated gameobjects of type T
35
+
a_iStartSize is the amount of gameobjects of type T that will be instantiated on start
0 commit comments