Hi
I have a main menu, that goes to other sub menus which are all different scenes.
I would like to play the same music throughout the menu scenes, but then when you go to the game scene to change music.
Any ideas?
Thanks, Chris
Hi
I have a main menu, that goes to other sub menus which are all different scenes.
I would like to play the same music throughout the menu scenes, but then when you go to the game scene to change music.
Any ideas?
Thanks, Chris
One way to do it is to have the music played from a gameoject that's set `DontDestroyOnLoad` using a script. When the first game scene starts, destroy this gameobject with `Destroy` and start the new music. So in javascript you would get something like this:
Create a game object in first menu scene with name MenuMusic, add sound source component playing your music automatically and the following script:
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);
}
In the first game scene add a gameobject named 'GameMusic' (also with music source playing the correct music) and script:
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);
}
the answer is set music to awake on splash screen