示例#1
0
        static void CreateSharedInstance()
        {
            GameObject obj = new GameObject("GameObject Pool Controller");

            DontDestroyOnLoad(obj);
            instance = obj.AddComponent <GameObjectPoolController>();
        }
 public virtual void Enqueue(Poolable item)
 {
     if (willEnqueue != null)
     {
         willEnqueue(item);
     }
     GameObjectPoolController.Enqueue(item);
 }
 public void Register()
 {
     if (string.IsNullOrEmpty(key))
     {
         key = prefab.name;
     }
     GameObjectPoolController.AddEntry(key, prefab, prepopulate, maxCount);
     isRegistered = true;
 }
        public virtual Poolable Dequeue()
        {
            Poolable item = GameObjectPoolController.Dequeue(key);

            if (didDequeue != null)
            {
                didDequeue(item);
            }
            return(item);
        }
示例#5
0
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this);
     }
     else
     {
         instance = this;
     }
 }
 public void UnRegister()
 {
     GameObjectPoolController.ClearEntry(key);
     isRegistered = false;
 }