0
\$\begingroup\$

My Question is simple i just want to Mute/Pause All Sound of the Game having different scenes.

From Scene 1 Which is a Main Menu I Have Two Button On/Off . When i press On Button it stops or mute full game sound or music like Car sound etc in all Scenes. When i press off button then Sound become active again in all scenes ..

I'm new in this field so please give me some help My Game is almost Complete But i can not Control or Mute All scene Sound at the same time..Waiting

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

Simply saving the audio volume to PlayerPrefs and then loading it on every scene should do the trick:

// When off is pressed
PlayerPrefs.SetFloat("volume", 0.0F);

// In every scene
AudioListener.volume = PlayerPrefs.GetFloat("volume");

To enable the volume simply change the volume value to something larger than 0.

\$\endgroup\$
3
  • \$\begingroup\$ thank you brother .... But how to save each scene audiolistner to playerprefs ....... Please Please Explain a Little bit By Some Text etc ... \$\endgroup\$ Jul 29, 2017 at 17:34
  • \$\begingroup\$ Perhaps you don't have to change the audio every scene. Try just changing it when you press the button. \$\endgroup\$
    – Charanor
    Jul 29, 2017 at 18:07
  • \$\begingroup\$ But My On /Off Button is located on Main Menu Canves which is a scene one and these button control 20 other scene audio ..... what changes i do in 20 other scenes ? \$\endgroup\$ Jul 29, 2017 at 18:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .