for some reason, my slider and audio resets back to 1 when I stop and play the game after I changed the value. Here is the code, I can’t spot anything wrong with it:
//sliderText.cs - created by Kyle 06 Jan 2015
//Attach to option sliders
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class sliderText : MonoBehaviour {
public AudioSource music;
public Slider Master;
public Slider MusicSlider;
public Slider Voice;
public Slider SFX;
public Slider MouseSpeed;
public Slider FOV;
public Text MasterTxt;
public Text MusicTxt;
public Text VoiceTxt;
public Text SFXTxt;
public Text MouseSpeedTxt;
public Text FOVTxt;
/*public Text Text;
public Slider Slider;*/
void Start(){
audio.volume = PlayerPrefs.GetFloat("CurVol");
MusicSlider.value = audio.volume;
MusicTxt.text = "" + MusicSlider.value;
}
// Update is called once per frame
void Update () {
//Text.text = "" + Slider.value;
MasterTxt.text = "" + Master.value;
MusicTxt.text = "" + MusicSlider.value;
VoiceTxt.text = "" + Voice.value;
SFXTxt.text = "" + SFX.value;
MouseSpeedTxt.text = "" + MouseSpeed.value;
FOVTxt.text = "" + FOV.value;
}
public void VolumeControl(float volumeControl){
audio.volume = volumeControl;
PlayerPrefs.SetFloat("CurVol", audio.volume);
}
}