Hello!
I managed to find a way to have a menu song that doesn’t start over between different menu scenes, but I’d like it to stop when I load a playable level. The menu music just seems to turn to a REALLY low volume, but it is still audible.
These two scripts are taking care of the menu music. Could you please find a solution for me?
public class MyUnitySingleton : MonoBehaviour {
private static MyUnitySingleton instance = null;
public static MyUnitySingleton Instance {
get { return instance; }
}
void Awake() {
if (instance != null && instance != this) {
Destroy(this.gameObject);
return;
} else {
instance = this;
}
DontDestroyOnLoad(this.gameObject);
}
}
.
public class MusicManager : MonoBehaviour {
public AudioClip NewMusic; //Pick an audio track to play.
public GameObject go;
void Awake () {
go = GameObject.Find("Game Music");
//Finds the game object called Game Music, if it goes by a different name, change this. go.audio.clip = NewMusic;
//Replaces the old audio with the new one set in the inspector. go.audio.Play();
//Plays the audio.
}
}