コード例 #1
0
        public virtual IPrefabComponent Spawn(PrefabType type, Vector3 position, Quaternion rotation)
        {
            IPrefabComponent prefab;

#if UNITY_EDITOR
            // if not playing, use the prefab mode
            if (!Application.isPlaying)
            {
                var prefabgo = this.InstantiateSafe(_prefabs[(int)type], position, rotation);
                prefab = prefabgo.GetComponent <IPrefabComponent>();
            }
            else
            {
#endif
            // if playing, use the pools
            prefab = PrefabManagerPoolSystem.Get(type, position, rotation);

#if UNITY_EDITOR
        }
#endif
            prefab.SetPrefabType(type);

            if (OnSpawn != null)
            {
                OnSpawn(prefab);
            }

            return(prefab);
        }
コード例 #2
0
        public virtual void Return(IPrefabComponent prefab)
        {
#if UNITY_EDITOR
            // if not playing, use the prefab mode
            if (!Application.isPlaying)
            {
                this.DestroySafe(prefab.gameObject);
            }
            else
            {
#endif
            // if playing, use the pools
            PrefabManagerPoolSystem.Return(prefab);

#if UNITY_EDITOR
        }
#endif
        }
コード例 #3
0
 private void Awake()
 {
     PrefabManagerPoolSystem.InitAllPools(_initialInstanceCount);
 }