Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MonoBehaviourPool{T}"/> class.
 /// </summary>
 /// <param name="prefab">The prefab used to instantiate objects from.</param>
 /// <param name="initialCount">The initial count of objects to create.</param>
 /// <param name="setToSleep">A function called on objects when they are put to sleep.</param>
 /// <param name="wakeUp">A function called on an object when it is woken up.</param>
 public MonoBehaviourPool(T prefab, GameObject root, int initialCount, Action <T> wakeUp, Action <T> setToSleep)
 {
     pool = new Pool <T>(
         initialCount,
         () => GLMonoBehaviour.Instantiate(prefab, root),
         (obj) => UnityEngine.Object.Destroy(obj.gameObject),
         wakeUp,
         setToSleep);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Clones an object.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="obj"></param>
 /// <returns></returns>
 public static T Clone <T>(this T obj) where T : MonoBehaviour
 {
     return(GLMonoBehaviour.Instantiate <T>(obj));
 }