using System; using System.Collections.Generic; using UnityEngine; using wf; public class PhotoSliderAndInput : MonoBehaviour { public void Awake() { if (!this.is_awake_) { this.is_awake_ = true; NDebug.AssertNull(this.SliderObject != null); if (this.InputObject != null) { EventDelegate.Add(this.InputObject.onChange, new EventDelegate.Callback(this.OnTextChange)); } EventDelegate.Add(this.SliderObject.onChange, new EventDelegate.Callback(this.OnSliderChange)); if (this.IsNumInt) { this.MinNum = (float)((int)this.MinNum); this.MaxNum = (float)((int)this.MaxNum); } } } public void ResetValue() { this.Awake(); this.value = this.ResetNum; } private void OnTextChange() { if (this.fix_update_) { return; } float num = this.MinNum; try { num = float.Parse(UIInput.current.value); if (this.IsNumInt) { num = (float)((int)num); } num = wf.Math.RoundMinMax(num, this.MinNum, this.MaxNum); } catch { return; } this.SliderObject.value = (num - this.MinNum) / (this.MaxNum - this.MinNum); } private void OnSliderChange() { if (this.fix_update_) { return; } float num = this.MinNum; try { num = this.MinNum + (this.MaxNum - this.MinNum) * this.SliderObject.value; if (this.IsNumInt) { num = (float)((int)num); } num = wf.Math.RoundMinMax(num, this.MinNum, this.MaxNum); } catch { return; } if (this.InputObject != null) { this.fix_update_ = true; this.InputObject.value = num.ToString(); this.fix_update_ = false; } for (int i = 0; i < this.onChangeValue.Count; i++) { this.onChangeValue[i](this.value); } } public string text { get { return (!(this.InputObject != null)) ? string.Empty : this.InputObject.value; } set { if (this.InputObject != null) { this.InputObject.value = value; } } } public float value { get { return this.MinNum + (this.MaxNum - this.MinNum) * this.SliderObject.value; } set { this.Awake(); float num = value; if (this.IsNumInt) { num = (float)((int)num); } num = wf.Math.RoundMinMax(num, this.MinNum, this.MaxNum); this.SliderObject.value = (num - this.MinNum) / (this.MaxNum - this.MinNum); this.text = num.ToString(); } } public bool visible { get { return base.gameObject.activeSelf; } set { base.gameObject.SetActive(value); } } public new bool enabled { get { return this.SliderObject.thumb.GetComponent().isEnabled; } set { this.SliderObject.thumb.GetComponent().isEnabled = value; this.SliderObject.GetComponent().enabled = value; if (this.InputObject != null) { this.InputObject.enabled = value; } } } public UIInput InputObject; public UISlider SliderObject; public float MinNum; public float MaxNum; public float ResetNum; public bool IsNumInt; public List> onChangeValue = new List>(); private bool fix_update_; private bool is_awake_; }