/// <summary> Stop all SoundyControllers from playing and destroys the GameObjects they are attached to </summary> public static void KillAllControllers() { if (Instance.DebugComponent) { DDebug.Log("Kill All Controllers", Instance); } SoundyController.KillAll(); }
/// <summary> Stops all SoundyControllers from playing, destroys the GameObjects they are attached to and clears the Pool </summary> /// <param name="keepMinimumNumberOfControllers"> Should there be a minimum set number of controllers in the pool left after clearing? </param> public static void ClearPool(bool keepMinimumNumberOfControllers = false) { if (keepMinimumNumberOfControllers) { RemoveNullControllersFromThePool(); //remove any null controllers (sanity check) if (Pool.Count <= MinimumNumberOfControllers) //make sure the minimum number of controllers are in the pool before killing them { if (Instance.DebugComponent) { DDebug.Log("Clear Pool - " + Pool.Count + " Controllers Available", Instance); } return; } int killedControllersCount = 0; for (int i = Pool.Count - 1; i >= MinimumNumberOfControllers; i--) //go through the pool { SoundyController controller = Pool[i]; Pool.Remove(controller); //remove controller from the pool controller.Kill(); //kill the controller killedControllersCount++; } if (Instance.DebugComponent) { DDebug.Log("Clear Pool - Killed " + killedControllersCount + " Controllers - " + Pool.Count + "' Controllers Available", Instance); } return; } SoundyController.KillAll(); Pool.Clear(); if (Instance.DebugComponent) { DDebug.Log("Clear Pool - Killed All Controllers - " + Pool.Count + " Controllers Available", Instance); } }