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>()); }
public virtual void RemoveSpawnedEntry(GameObject clone, Transform trs) { SpawnedEntry spawnedEntry = new SpawnedEntry(clone, trs); spawnedEntries.Remove(spawnedEntry); }
public virtual void RemoveSpawnedEntry(SpawnedEntry spawnedEntry) { spawnedEntries.Remove(spawnedEntry); }
public virtual KeyValuePair <GameObject, Transform> Despawn(SpawnedEntry spawnedEntry) { return(Despawn(spawnedEntry.prefabIndex, spawnedEntry.go, spawnedEntry.trs)); }
public virtual GameObject Despawn(SpawnedEntry spawnedEntry) { return(Despawn(spawnedEntry.prefabIndex, spawnedEntry.go, spawnedEntry.trs)); }