Пример #1
0
        public void DespawnPrefab()
        {
            if (spawnedPrefabs.Count > 0)
            {
                // Get the last clone
                var clone = spawnedPrefabs.Pop();

                // Despawn it
                LeanPool.Despawn(clone);
            }
        }
Пример #2
0
        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);
        }
Пример #3
0
        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");
        }
Пример #4
0
 public virtual void Despawn()
 {
     LeanPool.Despawn(gameObject);
 }