Exemplo n.º 1
0
        public GameObject Spawn()
        {
            GameObject spawnedObject = PoolManager.Spawn(this.prefab, this.transform.position, this.transform.rotation);

            this.spawnedObjects.Add(spawnedObject);
            SpawnTracker spawnTracker = spawnedObject.GetComponent <SpawnTracker>();

            if (spawnTracker == null)
            {
                spawnTracker = spawnedObject.AddComponent <SpawnTracker>();
            }
            spawnTracker.Spawner = this;

            return(spawnedObject);
        }
        public void Destroy()
        {
            if (this.destroyEffectPrefab != null)
            {
                GameObject destroyEffect = PoolManager.Spawn(this.destroyEffectPrefab, this.transform.position);
                destroyEffect.transform.SetParent(this.transform.parent);
            }

            if (this.delay > 0)
            {
                StartCoroutine(DelayedDestroyCoroutine());
            }
            else
            {
                RemoveObject();
            }
        }