Пример #1
0
        public virtual T SpawnComponent <T> (int prefabIndex, Vector3 position = new Vector3(), Quaternion rotation = new Quaternion(), Transform parent = null)
        {
            SpawnEntry spawnEntry = spawnEntries[prefabIndex];

            while (spawnEntry.cache.Length <= spawnEntry.preload)
            {
                Preload(prefabIndex);
            }
            KeyValuePair <GameObject, Transform> cacheEntry = spawnEntry.cache[0];
            GameObject clone = cacheEntry.Key;

            if (clone == null)
            {
                return(default(T));
            }
            spawnEntry.cache = spawnEntry.cache.RemoveAt(0);
            SpawnedEntry entry = new SpawnedEntry(clone, cacheEntry.Value);

            entry.prefab         = spawnEntry.prefab;
            entry.prefabIndex    = prefabIndex;
            entry.trs.position   = position;
            entry.trs.rotation   = rotation;
            entry.trs.localScale = spawnEntry.trs.localScale;
            entry.trs.SetParent(parent, true);
            clone.SetActive(true);
            spawnedEntries = spawnedEntries.Add(entry);
            return(entry.go.GetComponent <T>());
        }
Пример #2
0
        public virtual void RemoveSpawnedEntry(GameObject clone, Transform trs)
        {
            SpawnedEntry spawnedEntry = new SpawnedEntry(clone, trs);

            spawnedEntries.Remove(spawnedEntry);
        }
Пример #3
0
 public virtual void RemoveSpawnedEntry(SpawnedEntry spawnedEntry)
 {
     spawnedEntries.Remove(spawnedEntry);
 }
Пример #4
0
 public virtual KeyValuePair <GameObject, Transform> Despawn(SpawnedEntry spawnedEntry)
 {
     return(Despawn(spawnedEntry.prefabIndex, spawnedEntry.go, spawnedEntry.trs));
 }
Пример #5
0
 public virtual GameObject Despawn(SpawnedEntry spawnedEntry)
 {
     return(Despawn(spawnedEntry.prefabIndex, spawnedEntry.go, spawnedEntry.trs));
 }