public static void Play(string resourceName, float volume = 1.0f) { // surprisingly, that doesn't override background music, but rather // attaches new sound to the same AudioSource BackgroundMusic.PlayOneShot(LoadAudio(resourceName), volume); }
private void Awake() { var backgroundMusic = GameObject.Find("BackgroundMusic"); if (backgroundMusic != null) { m_bgMusic = backgroundMusic.GetComponent <BackgroundMusic>(); if (m_bgMusic != null) { m_bgMusic.FadeOut(); } } }
private void Awake() { if (Instance != null) { DestroyImmediate(gameObject); } else { DontDestroyOnLoad(gameObject); Instance = this; m_audioSource = GetComponent <AudioSource>(); m_audioSource.ignoreListenerVolume = true; } }