using System; using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; public class ToggleOption : MonoBehaviour { public Toggle toggle; public String prefToChange; public Slider slider; public TMP_InputField inputField; void Start() { if (!PlayerPrefs.HasKey(prefToChange)) { Debug.Log("SettingDefault"); PlayerPrefs.SetInt(prefToChange, 1); } toggle.isOn = PlayerPrefs.GetInt(prefToChange) == 1; if (slider != null) { slider.enabled = toggle.isOn; inputField.enabled = toggle.isOn; } } public void OnToggleChange() { PlayerPrefs.SetInt(prefToChange, toggle.isOn ? 1 : 0); slider.enabled = toggle.isOn; inputField.enabled = toggle.isOn; } }