예제 #1
0
        GameObject _Instantiate()
        {
            GameObject o = GameObject.Instantiate(_prefab) as GameObject;

            //Always add a factoryReleaser to simplify deallocation
            PoolReleaser releaser = o.GetComponent <PoolReleaser>();

            if (releaser == null)
            {
                releaser = o.gameObject.AddComponent <PoolReleaser>();
            }
            releaser.mSetDelegate(new PoolReleaser.ReleaseDelegate(_Release), o);


            o.transform.parent = _parent;
            _used.Add(o);
            o.name = _prefab.name + "_" + _used.Count;
            return(o);
        }
예제 #2
0
        T _Instantiate()
        {
            T o = Component.Instantiate(_prefab) as T;

            if (o == null)
            {
                Debug.Log(string.Format("Can not instantiate {0}", _prefab.name));
            }

            //Always add a factoryReleaser to simplify deallocation
            PoolReleaser releaser = o.GetComponent <PoolReleaser>();

            if (releaser == null)
            {
                releaser = o.gameObject.AddComponent <PoolReleaser>();
            }
            releaser.mSetDelegate(new PoolReleaser.ReleaseDelegate(_Release), o);//.mSetFactory(this);


            o.transform.parent = _parent;
            _used.Add(o);
            o.name = _prefab.name + "_" + _used.Count;
            return(o);
        }