예제 #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);
 }