/** * Returns the MusicController singleton instance. * Will create a MusicController game object if none currently exists. */ public static MusicController GetInstance() { if (instance == null) { GameObject go = new GameObject("MusicController"); DontDestroyOnLoad(go); instance = go.AddComponent<MusicController>(); } return instance; }
public override void OnEnter() { MusicController musicController = MusicController.GetInstance(); if (musicController != null) { musicController.SetAudioVolume(volume, fadeDuration, () => { if (waitUntilFinished) { Continue(); } }); } if (!waitUntilFinished) { Continue(); } }
public override void OnEnter() { System.Action onComplete = () => { if (waitUntilFinished) { Continue(); } }; MusicController musicController = MusicController.GetInstance(); if (musicController != null) { musicController.SetAudioPitch(pitch, fadeDuration, onComplete); } if (!waitUntilFinished) { Continue(); } }
public override void OnEnter() { if (soundClip == null) { Continue(); return; } MusicController musicController = MusicController.GetInstance(); if (musicController != null) { musicController.PlaySound(soundClip, volume); } if (waitUntilFinished) { Invoke("DoWait", soundClip.length); } else { Continue(); } }