I want to know how to make a cross scene mute button and unmute button. I have tried a dontdestroyonload for seamless music but I dont know how to make a mute and mute button for it. Any ideas?
Thanks!
Use AudioListener.volume: Unity - Scripting API: AudioListener.volume, or if it’s just for a single audio source, use AudioSource.volume: Unity - Scripting API: AudioSource.volume
This works very well but is there a way to change the way it looks?
How to change the way what looks? The button?
The sliders. Sorry for not clarifying.
Also, is there a way to move it somewhere else?
Of course. If you look at the slider in your scene hierarchy you’ll see it’s actually made of a small hierarchy of different GameObjects. I encourage you to poke around in there. For example, there’s an image component for the “handle”, there’s an image component for the “filled” area, there’s an image component for the “unfilled” background. You can change these sprites to your liking.
As for positioning, yes of course. A slider is like any UI element in Unity. Here’s an article about how positioning UI elements works in Unity: Basic Layout | Unity UI | 1.0.0
I cant find the slider in the hierarchy. I applied the script to my empty gameobject with the music player and I didn’t have to even make a slider it made one its self. Did I apply it wrong? Thank you for helping me so far!
It made this itself:
Ok so I just realized you’re probably talking about the example script from this link: https://docs.unity3d.com/ScriptReference/AudioSource-volume.html
Is that correct? That script is just an example of how to use the “volume” property of an AudioSource from a script. You aren’t meant to copy the script into your project. It’s using the outdated OnGUI method to draw that slider, which is much harder to customize than the modern Unity UI.
I did copy it. I dont know much about scripting though.
Is there any tutorials I could watch to help me?
Thank you for replying!