- Home /
Options Menu with volume sliders accessible from Main Menu scene and Game scene
Hi Noob here, and I've watch many videos showing how to make sliders that control music and sound effects volumes. This has worked fine. For example https://www.youtube.com/watch?v=EA-tBcTxE8M&t=1635s
My Main Menu is a scene. It allows you to click options, where a new object/canvas/panel is set active to allow the changing of 2 sliders. The volumes are set fine.
What about accessing this Options Menu by pressing the ESCAPE key while playing the game. I am having difficulty and I have spent hours going around in circles.
I cannot load the Main Menu scene again because this would stop and reset the progress of the game.
I (maybe) should not make a new GameObject/Canvas/Sliders because this is duplication, and it may be difficult to access the scripts or AudioSources.
What I have been trying is making the MenuManager object and therefore script DontDestroyOnLoad, making the AudioManager object and therefore script DontDestroyOnLoad, and the OptionsUI object DontDestroyOnLoad.
This has caused hours of headaches. Since I don't want the OptionsUI to show when the game loads, I need to set it to inactive. But if it is inactive, when I enter the game scene, I cannot get a reference to it and therefore I cannot show it again if the user presses ESC. So I fixed this with placeholder objects and using the scripts to find the OptionsUI on Awake and then quickly set it inactive. But then I've had trouble with duplicate GameObjects when returning to the Main Menu, and I've played with singletons, and I've created a mess.
I think I am going about this all wrong. So my question is:
What is the best way to have a volume slider for music and a volume slider for sound effects accessible from multiple scenes?
Answer by Casiell · Oct 30, 2018 at 02:07 PM
Have your managers on an always active game object and only turn on/off your UI. Also keep a reference to UI in managers so you never have to look for it from outside.
Answer by Solid_9 · Sep 10, 2021 at 12:42 PM
My problem is pretty much but the difference is that I want to change volume from menu scene and have effect on game scene. I don't want to change the volumes for game scene. So for that, I created 2 empty objects 1in menu scene and other one in game scene with same audio clip but i can't access the audio source from game scene(since it's not created). So, what should i do? ,My problem is pretty much but the difference is that I want to change volume from menu scene and have effect on game scene. I don't want to change the volumes for game scene. Any help??