Ejemplo n.º 1
0
        public virtual GameObject Get(Vector3 pos, Quaternion rot, float life_time)
        {
            GameObject get_object = null;

            if (object_pool_queue.Count == 0)
            {
                get_object = GameObject.Instantiate(_prefab);
                ObjectRecover _recover = get_object.AddComponent <ObjectRecover>();
                _recover.recover_call_back = Remove;
            }
            else
            {
                get_object = object_pool_queue.Dequeue();
            }
            get_object.GetComponent <ObjectRecover>().Recover(life_time);
            get_object.SetActive(true);
            get_object.transform.position = pos;
            get_object.transform.rotation = rot;
            return(get_object);
        }
Ejemplo n.º 2
0
        public virtual GameObject Get(Transform transform, float life_time)
        {
            GameObject get_object = null;

            if (object_pool_queue.Count == 0)
            {
                get_object = GameObject.Instantiate(_prefab);
                ObjectRecover _recover = get_object.AddComponent <ObjectRecover>();
                _recover.recover_call_back = Remove;
                object_list.Add(get_object);
            }
            else
            {
                get_object = object_pool_queue.Dequeue();
            }
            get_object.GetComponent <ObjectRecover>().Recover(life_time);
            get_object.transform.parent        = transform;
            get_object.transform.localPosition = Vector3.zero;
            get_object.transform.localScale    = Vector3.one;
            get_object.SetActive(true);
            return(get_object);
        }