I want to save my slider's value so when I change scences, the values remain the same and also retarting the game, it reamins the same. Here is my code so far which is on an empty game object with the sliders for X and Y sensitivity in it.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class sliderSaves : MonoBehaviour {
public Slider XSlider;
public Slider YSlider;
// Use this for initialization
void Start () {
PlayerPrefs.SetFloat("OptionScore", XSlider.value);
PlayerPrefs.SetFloat("OptionLives", YSlider.value);
XSlider.value = PlayerPrefs.GetFloat("OptionScore");
YSlider.value = PlayerPrefs.GetFloat("OptionLives");
PlayerPrefs.Save();
}
}
↧