Quantcast
Channel: Questions in topic: "playerprefs"
Viewing all articles
Browse latest Browse all 1333

Slider value saving?

$
0
0
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(); } }

Viewing all articles
Browse latest Browse all 1333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>