Hi,
I have an object in my main menu scene with an audio source component + audio file, and a script attached called scriptBackgroundMusic:
#pragma strict
private static var instance:scriptBackgroundMusic;
public static function GetInstance() : scriptBackgroundMusic {
return instance;
}
function Awake() {
if (instance != null instance != this) {
Destroy(this.gameObject);
return;
} else {
instance = this;
}
DontDestroyOnLoad(this.gameObject);
}
…the music plays on the main menu. However, when I start level 1 the music stops. I can’t figure out why this is happening. Any ideas?
My level load script is simply:
function OnGUI(){
if(GUI.Button(Rect(375,250,100,30), "Start Game"))
{
Application.LoadLevel("sceneLevel01"); //Load the game level
}
if(GUI.Button(Rect(375,290,100,30), "Exit"))
{
Application.Quit(); //Exit game (only works in final build)
}
}
Thanks!