i have just done a nice mute for music, which im happy about. but now i really want to make sure that when my scene resets for each game, then mute does not revert back to its off state.
here is my current music mute code, which works perfectly. just what i need. but can’t get the state of the toggle to stay as it should when resetting the scene.
have tried a ‘DontDestroyOnLoad’ for just the toggle, but not working. weird.
thanks to anyone who can help
public bool isMute;
public void MuteToggle(){
isMute = !isMute;
if (isMute == true) {
AudioListener.volume = 0;
} else {
AudioListener.volume = 1;
}
}
but im slightly confused as to how his would incorporate into the mute code from what i posted.
what i also have set up is a separate toggle state for the toggle mute itself. but really do not know where this code you have posted would go. i have played with it, but really am not getting anything.
a mixture of everything. though have started to just nail on unity.
had down lua, c++, some java/JS. though unity has been the first that i have really wanted to now stay in lately
This will make the game object live between scenes; Yes the value should keep for the owner script is not being destroyed… Where and how MuteToggle is called?
the mute toggle shows when the player dies. a canvas pops up in the same scene, this holds things like a quit button, which takes you back to the menu. also a retry button which loads the level again, then has a mute button which is the culprit in question
there are only 2 scenes in the whole game so far. but this will more than likely stay that way for a while
can anybody help on this please.
i am having the worst trouble getting it to work, and really this is the last piece of the puzzle. so any help that helps fix this would be great.
can nobody help me on this please. im having just a super hard time figuring this out.
again, all i need is help to stop my toggle from resetting position states. so if i hit mute, when i reload the level, the toggle is staying down. then if i hit unmute, it stays up.
i have the music code working perfectly. just this toggle is my last thing. I’ve been up since 8am trying to get this.
thank you to anyone who can help, even an example would be good to just learn from
again, thank you to anyone who can put this to bed
i have 2 scenes just now. there will be more, but this is just an initial thing.
but there is just a menu, then the game screen. the audio stuff, including music, sound and scripts are loaded in the game scene, since you will be that part the most.
when you die, a canvas pops up with a retry button, quit, mute sound and share screenshot.
the script for the sound is located in a game object which handles all my sound. i have another object which handles other non-audio things. such as restarting levels etc
this would make my day, and future games if this can be helped with