/// <summary> /// Destroy and start destruction of effect /// </summary> protected virtual void OnDisable() { if (m_SpawnedEffect == null) { return; } // Initiate destruction timer if (m_DestroyTimer != null) { m_DestroyTimer.enabled = true; if (m_Resetter != null) { m_Resetter.StopAll(); } } else { // Repool immediately Poolable.TryPool(m_SpawnedEffect); } m_SpawnedEffect = null; m_DestroyTimer = null; }
/// <summary> /// Spawn our effect /// </summary> protected virtual void OnFired() { if (effectPrefab != null) { m_SpawnedEffect = Poolable.TryGetPoolable(effectPrefab); m_SpawnedEffect.transform.parent = null; m_SpawnedEffect.transform.position = followTransform.position; m_SpawnedEffect.transform.rotation = followTransform.rotation; // Make sure to disable timer if it's on initially, so it doesn't destroy this object m_DestroyTimer = m_SpawnedEffect.GetComponent <SelfDestroyTimer>(); if (m_DestroyTimer != null) { m_DestroyTimer.enabled = false; } m_Resetter = m_SpawnedEffect.GetComponent <PoolableEffect>(); if (m_Resetter != null) { m_Resetter.TurnOnAllSystems(); } } }