Exemple #1
0
        public T Get <T>(Vector3 position, Quaternion rotation, Transform parent) where T : IObjectPool
        {
            IObjectPool res = null;

            if (queue.Count == 0)
            {
                res = create();
            }
            else
            {
                res = queue.Dequeue();
            }
            availablePools.Add(res, this);

            res.gameObject.transform.position = position;
            res.gameObject.transform.rotation = rotation;
            res.gameObject.transform.SetParent(parent, false);

            res.gameObject.SetActive(true);

            res.OnCreate();

            return((T)res);
        }