Hello, I’m using DontDestroyOnLoad to play music through various menu scenes, the code looks like :
function Awake() {
// see if we've got game music still playing
var gameMusic : GameObject = GameObject.Find("GameMusic");
if (gameMusic) {
// kill game music
Destroy(gameMusic);
}
// make sure we survive going to different scenes
DontDestroyOnLoad(gameObject);
}
function Awake() {
// see if we've got menu music still playing
var menuMusic : GameObject = GameObject.Find("MenuMusic");
if (menuMusic) {
// kill menu music
Destroy(menuMusic);
}
// make sure we survive going to different scenes
DontDestroyOnLoad(gameObject);
}
since I have used play on awake, the music starts from beginning whenever I move back from submenu’s to the main menu…Then I will have two music playing at the same time…
Is there any way I could stop this from happening?