コード例 #1
0
        /// <summary>
        /// Initializes values and subscribes listeners to events.
        /// </summary>
        protected virtual void Awake()
        {
            toggle = GetComponent <Toggle>();
            toggle.onValueChanged.AddListener((bool _) => OnValueChange(_));             //UI classes use Unity events, requiring delegates (delegate() { OnValueChange(); }) or lambda expressions (() => OnValueChange()). Listeners are not persistent, so no need to unsub
            //Restores saved value if there is one, else default. After subscribing so OnValueChange sets value

            Value = OptionSaveSystem.LoadBool(optionName, defaultSetting.value);             //Saved value if there is one, else default. After subscribing so OnValueChange applies setting
        }
コード例 #2
0
 protected void OnValueChange(int _value)
 {
     OptionSaveSystem.SaveInt(optionName, _value);
     ApplySetting(_value);
     if (allowPresetCallback && preset != null)
     {
         preset.SetCustom();
     }
 }
コード例 #3
0
        /// <summary>
        /// Initializes values and subscribes listeners to events.
        /// </summary>
        protected virtual void Awake()
        {
#if TMP_PRESENT
            dropdown = GetComponent <TMPro.TMP_Dropdown>();
#else
            dropdown = GetComponent <Dropdown>();
#endif
            dropdown.onValueChanged.AddListener((int _) => OnValueChange(_));             //UI classes use Unity events, requiring delegates (delegate() { OnValueChange(); }) or lambda expressions (() => OnValueChange()). Listeners are not persistent, so no need to unsub
            Value = OptionSaveSystem.LoadInt(optionName, defaultSetting.value);           //Saved value if there is one, else default. After subscribing so OnValueChange applies setting
        }
コード例 #4
0
 void Awake()
 {
     GetComponent <Button>().onClick.AddListener(() => OptionSaveSystem.SaveToDisk());
 }
コード例 #5
0
 /// <summary>
 /// Initializes values and subscribes listeners to events.
 /// </summary>
 protected virtual void Awake()
 {
     slider = GetComponent <Slider>();
     slider.onValueChanged.AddListener((float _) => OnValueChange(_));             //UI classes use Unity events, requiring delegates (delegate() { OnValueChange(); }) or lambda expressions (() => OnValueChange()). Listeners are not persistent, so no need to unsub
     Value = OptionSaveSystem.LoadFloat(optionName, defaultSetting.value);         //Saved value if there is one, else default. After subscribing so OnValueChange applies setting
 }