hello, i am making a 2d platformer with different level.
on the level 1 I made a gameobject with this script:
private static var instance:MyUnitySingleton;
public static function GetInstance() : MyUnitySingleton {
return instance;
}
function Awake() {
if (instance != null instance != this) {
Destroy(this.gameObject);
return;
} else {
instance = this;
}
DontDestroyOnLoad(this.gameObject);
}
and in the level 2 I want to change the music, thats why I made a gameobject with this script:
var NewMusic: AudioClip; //Pick an audio track to play.
function Awake ()
{
var 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.
}
everything works just fine, the music plays in level 1 and when I die the music don’t start from the beginning.
and when I completed level 1 the music changes in level 2 just perfect, but when I die in level 2 the music don’t continous playing, it starts from the beginning!! how can I make the music don’t stop playing when I respawn in level 2?