Okay, I’ve been Googling info on how to create a volume slider for a few days now, and can’t find anything recent that I actually understand. Here’s what I attempted to do.
I’ve got a bunch of objects that play an audio clip when they are interacted with by a user or other objects. The audio clip is attached to those objects, and those objects are all tagged with the tag “Crystal”.
I created a slider, and the OnValueChanged() is connected to my GameController.AudioSlider(), which is as follows:
That doesn’t seem to be the problem. All the Crystal objects are generated from a prefab, which is where the audio source is located. To be sure, I checked each individual crystal to verify…
Ok, so I tried changing my script to the following to use the AudioListener volume instead.
public void AudioSlider(float volume)
{
Camera.main.GetComponent().volume = volume / 100;
}
And now get the error:
Assets/Scripts/GameController.cs(237,59): error CS0176: Static member `UnityEngine.AudioListener.volume’ cannot be accessed with an instance reference, qualify it with a type name instead