using System; using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; public class SliderOption : MonoBehaviour { public OptionsMenu optionsMenu; private bool setPref = false; public TextMeshProUGUI label; public Slider slider; public TMP_InputField inputField; public String settingToChange; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { if (!setPref && optionsMenu.hasSetUp && slider != null) { slider.value = (float) Math.Round(PlayerPrefs.GetFloat(settingToChange), 3); inputField.text = slider.value.ToString(); } } public void SliderChange() { PlayerPrefs.SetFloat(settingToChange, slider.value); inputField.text = Math.Round(slider.value, 3).ToString(); } public void TextFieldChange() { float value; if(float.TryParse(inputField.text, out value)) { if (value <= slider.maxValue && value >= slider.minValue) { PlayerPrefs.SetFloat(settingToChange, value); slider.value = value; } } } }