Hi everyone!
I have a slight issue with my game , specifically with my audio slider.
The saved audio value is being loaded only when I’m navigating into my menu scenes audio menu (it has the slider childed to it).
The desired function is to load the audio value at the beginning of the game in the start scene but I couldn’t figured it out yet how to do it.
Any help is appreciated!
Here is the script of my slider:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Audio;
public class MusicSlider : MonoBehaviour {
public AudioMixer audioMixer;
public Slider musicSlider;
public void Start()
{
musicSlider.value = PlayerPrefs.GetFloat("Music",1f);
}
public void AdjustVolume(float volume)
{
PlayerPrefs.SetFloat("Music", volume);
audioMixer.SetFloat("Music", Mathf.Log10(volume) * 20);
}
}