public void DespawnPrefab() { if (spawnedPrefabs.Count > 0) { // Get the last clone var clone = spawnedPrefabs.Pop(); // Despawn it LeanPool.Despawn(clone); } }
public void SpawnPrefab() { // Randomly calculate a position var position = (Vector3)Random.insideUnitCircle * 6.0f; // Spawn a prefab clone var clone = LeanPool.Spawn(Prefab, position, Quaternion.identity, null); // Despawn it with a delay LeanPool.Despawn(clone, DespawnDelay); }
public void Despawn() { BeginBenchmark(); { // NOTE: Despawning in reverse spawn order is faster than spawn order for (var i = spawnedPrefabs.Count - 1; i >= 0; i--) { LeanPool.Despawn(spawnedPrefabs[i]); } spawnedPrefabs.Clear(); } EndBenchmark("Despawn"); }
public virtual void Despawn() { LeanPool.Despawn(gameObject); }