File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
Assets/JCSUnity/Scripts/UI/Slider Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,14 @@ public class JCS_SliderTextDisplay : JCS_TextObject
2020 {
2121 /* Variables */
2222
23+ public Action onRefresh = null ;
24+
25+ // Record for last min value.
26+ private float mMinVal = 0 ;
27+
28+ // Record for last max value.
29+ private float mMaxVal = 0 ;
30+
2331 [ Separator ( "Runtime Variables (JCS_TextSliderDisplay)" ) ]
2432
2533 [ Tooltip ( "To update the text along with this slider's value." ) ]
@@ -53,6 +61,14 @@ private void OnDisable()
5361 RemoveListener ( ) ;
5462 }
5563
64+ private void Update ( )
65+ {
66+ if ( mSlider == null )
67+ return ;
68+
69+ HandleMinMaxValueChanged ( ) ;
70+ }
71+
5672#if UNITY_EDITOR
5773 private void OnValidate ( )
5874 {
@@ -90,6 +106,21 @@ public void Refresh()
90106 Math . Round ( mSlider . value , mRoundPlace ) ,
91107 Math . Round ( mSlider . maxValue , mRoundPlace ) ,
92108 Math . Round ( mSlider . minValue , mRoundPlace ) ) ;
109+
110+ onRefresh ? . Invoke ( ) ;
111+ }
112+
113+ private void HandleMinMaxValueChanged ( )
114+ {
115+ if ( mMinVal != mSlider . minValue ||
116+ mMaxVal != mSlider . maxValue )
117+ {
118+ mMinVal = mSlider . minValue ;
119+ mMaxVal = mSlider . maxValue ;
120+
121+ // Handle min/max value change.
122+ Refresh ( ) ;
123+ }
93124 }
94125 }
95126}
You can’t perform that action at this time.
0 commit comments