- Home /
volume manager from scene to scene
Hey everyone,
volume manager works great.....however. I have the same script attached to 2 volume buttons WHICH ARE TOGGLES. 1 on my start scene, another on my play scene since they have different sounds they control. Below is my script and then my question.
public bool isMute;
public void IsMute()
{
isMute = !isMute;
AudioListener.volume = isMute ? 0 : 1;
}
so! on the start scene if I press the toggle, it will change the sprite (good) and the mute will carry over to the play scene (ALSO GOOD). the problem is the volume toggle in the play scene will not be on the right setting, so I will have to press it twice. once to get it to the correct sprite for the current volume setting and then again so that I can actually unmute it.
//how do i make it so that the toggle is already on the correct setting so that I only have to push it once instead of twice in the other scene
How are you changing the sprite? Is$$anonymous$$ute might not be being called the first time.
it's just a toggle, and the sprite looks like it's being changed when i press it, i definitely get the sprite swap to occur
Do you have a script for this? if so you could add something like
AudioListener.volume = GetComponent<Toggle>().isOn ? 0 : 1;
Answer by Nishchhal · Apr 30, 2019 at 07:32 PM
Why don't you add a Check to the Volume Checker Script which changes the sprite to mute or unmute. Like add this in an Init Method for that script that actually sets up the starting images or starting UI or simply add this check inside that Start Method which you use to change sprite
if(isMute) { //Enable Mute Sprite //Disable Unmute Sprite }
else { //Enable Unmute Sprite //Disable Mute Sprite }
Your answer
