- Home /
Working between different scenes!
I have a gameobject on Main Menu that contains a muted Audio Source. When I hit the Level 1 button, the Audio Source is unmuted and the music starts playing. Also, for this to happen the gameobject has "DontDestroyOnLoad".
Now I want to go back to the Main Menu by pressing another button, and I want the Audio Source to mute again. The thing is I'm not able to mute it, because I tried working with the "OnClick()" of the "Main Menu" button (the one that brings you back) to mute it, but I can't reference the gameobject because it's not on Level 1 yet! What I also tried was to order the Audio Source to mute when "button" is pressed, but I can't reference to the "Main Menu" button because it's on Level 1 :s (and gameobject is on MM).
I'd accept a workaround if this is really not possible.
Answer by Gnorpelzwerg · Dec 30, 2015 at 09:41 AM
Why don't you mute the GameObjects AudioSource every time the MM is loaded? By attaching a script to the GameObject...
void OnLevelWasLoaded(int level) {
if( level == int [id for MM] ) audioSource.enabled = false;
}