- Home /
During sound between scenes
Hi, i´m novice, i want create background sound, i tried some tutorial, but it isn´t what i want and himself i can´t create this, i´m in a learning stage, i have 2 menu scenes and 1 game i´m created the sounds during scenes, but it´s during game scene and this is what i won´t, i want so that sound during just between menu scenes and when is game scene loaded the menu music will be stopped how i can create this ? thank for help :) sorry for bad english
So, you start music during the menu scenes, but don't want it to continue playing when changing to gameplay scene? How are you starting the music currently? $$anonymous$$aybe you can post a bit of the code where you start it? As far as I know the music should not continue to play when changing scenes, unless you specifically set it to.
Answer by GEWLAR · Mar 07, 2014 at 09:12 AM
You will need a StartupScene (just use your first Scene for that). In this Scene you create a GameObject which handels the Music.
The Script on this GameObject needs function like this:
function Awake () {
DontDestroyOnLoad (transform.gameObject);
}
function Update () {
if(inMenu == false){
audio.mute = true;
}
else{
audio.mute = false;
}
}
As you see you need a Variable which tells the Script if you are in Menu or in Game.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Stop another sound from another script? 1 Answer
Menu Script Problem 0 Answers
How to make the trigger work only once. (SOUND) 1 Answer
Setting Background using NGUI 0 Answers