コード例 #1
0
        public Transform Spawn(Transform prefab, Vector3 pos, Quaternion rot, Transform parent)
        {
            Transform inst = null;

            PrefabPool tmpPool = GetPrefabPool(prefab);

            if (tmpPool == null)
            {
                tmpPool = new PrefabPool(prefab);
                CreatePrefabPool(tmpPool);
            }

            if (tmpPool != null)
            {
                inst = tmpPool.SpawnInstance(pos, rot);
                if (parent != null)
                {
                    var worldPositionStays = !(inst is RectTransform);
                    inst.SetParent(parent, worldPositionStays);
                    //inst.parent = parent;
                }
                else
                {
                    var worldPositionStays = !(inst is RectTransform);
                    inst.SetParent(Group, worldPositionStays);
                    //inst.parent = Group;
                }

                mSpawned.Add(inst);
                inst.gameObject.BroadcastMessage("OnSpawned", this, SendMessageOptions.DontRequireReceiver);
            }
            return(inst);
        }
コード例 #2
0
        public void CreatePrefabPool(PrefabPool prefabPool)
        {
            bool isAlreadyPool = GetPrefabPool(prefabPool.Prefab) == null ? false : true;

            if (isAlreadyPool)
            {
                return;
            }

            prefabPool.OwnedSpawnPool = this;
            mPrefabPools.Add(prefabPool);

            mPrefabs.Add(prefabPool.Prefab.name, prefabPool.Prefab);

            if (!prefabPool.PreLoaded)
            {
                prefabPool.PreloadInstances();
            }
        }
コード例 #3
0
        public Transform Spawn(Transform prefab, Vector3 pos, Quaternion rot, Transform parent)
        {
            Transform inst = null;

            PrefabPool tmpPool = GetPrefabPool(prefab);
            if (tmpPool == null)
            {
                tmpPool = new PrefabPool(prefab);
                CreatePrefabPool(tmpPool);
            }

            if (tmpPool != null)
            {
                inst = tmpPool.SpawnInstance(pos, rot);
                if (parent != null)
                {
                    var worldPositionStays = !(inst is RectTransform);
                    inst.SetParent(parent, worldPositionStays);
                    //inst.parent = parent;
                }
                else
                {
                    var worldPositionStays = !(inst is RectTransform);
                    inst.SetParent(Group, worldPositionStays);
                    //inst.parent = Group;
                }

                mSpawned.Add(inst);
                inst.gameObject.BroadcastMessage("OnSpawned", this, SendMessageOptions.DontRequireReceiver);
            }
            return inst;
        }
コード例 #4
0
        public void CreatePrefabPool(PrefabPool prefabPool)
        {
            bool isAlreadyPool = GetPrefabPool(prefabPool.Prefab) == null ? false : true;
            if (isAlreadyPool)
            {
                return;
            }

            prefabPool.OwnedSpawnPool = this;
            mPrefabPools.Add(prefabPool);

            mPrefabs.Add(prefabPool.Prefab.name, prefabPool.Prefab);

            if (!prefabPool.PreLoaded)
            {
                prefabPool.PreloadInstances();
            }
        }