Esempio n. 1
0
        public void ClearPool(PoolInstanceView poolInstanceView)
        {
            int poolKey = poolInstanceView.gameObject.GetInstanceID();

            if (pools.ContainsKey(poolKey))
            {
                pools[poolKey].Clear();
            }
        }
Esempio n. 2
0
        public PoolInstanceView ReusePoolInstance(PoolInstanceView poolInstanceView, Vector3 position, Quaternion rotation)
        {
            int poolKey = poolInstanceView.gameObject.GetInstanceID();

            if (pools.ContainsKey(poolKey))
            {
                return(pools[poolKey].ReusePoolInstance(position, rotation));
            }

            Debug.LogError("Cannot reuse non-existant pool instance");
            return(null);
        }
Esempio n. 3
0
        public PoolInstanceView ReusePoolInstance(Vector3 position, Quaternion rotation)
        {
            PoolInstanceView poolInstanceView = Dequeue();

            poolInstanceView.Position = position;
            poolInstanceView.Rotation = rotation;
            poolInstanceView.gameObject.SetActive(true);
            poolInstanceView.OnPoolInstanceReuse();

            Enqueue(poolInstanceView);

            return(poolInstanceView);
        }
Esempio n. 4
0
        public void Initialize()
        {
            GameObject prefab = poolRequest.poolInstanceView.gameObject;

            poolInstanceViews = new Queue <PoolInstanceView>();
            poolView.Name     = prefab.name + " pool";
            poolView.Parent   = objectPoolView.transform;

            for (int i = 0; i < poolRequest.poolSize; ++i)
            {
                PoolInstanceView poolInstanceView = container.InstantiatePrefab(prefab).GetComponent <PoolInstanceView>();
                poolInstanceView.Parent = poolView.transform;
                poolInstanceView.gameObject.SetActive(false);

                Enqueue(poolInstanceView);
            }
        }
Esempio n. 5
0
 public void Enqueue(PoolInstanceView poolInstanceView)
 {
     poolInstanceViews.Enqueue(poolInstanceView);
 }