private IEnumerator ListenForEmitDespawn() { yield return(new WaitForSeconds(targetParticle.main.startDelay.constantMax + 0.25f)); GameObject emitterGO = targetParticle.gameObject; float stayTimer = 0; while (targetParticle.IsAlive(true) && emitterGO.activeInHierarchy) { if (stayTimer > maxStayTime) { break; } stayTimer += Time.deltaTime; yield return(null); } yield return(null); timer = null; if (emitterGO.activeInHierarchy) { spawnPool?.Despawn(transform); targetParticle.Clear(true); } }
IEnumerator DespawnTimer() { float timer = 0; while (timer < time) { timer += Time.deltaTime; yield return(null); } this.timer = null; spawnPool?.Despawn(transform); }