File tree Expand file tree Collapse file tree 4 files changed +18
-3
lines changed
docs/ScriptReference/UI/Text Expand file tree Collapse file tree 4 files changed +18
-3
lines changed Original file line number Diff line number Diff line change 66 * $Notice: See LICENSE.txt for modification and distribution information
77 * Copyright © 2022 by Shen, Jen-Chieh $
88 */
9+ using System ;
910using UnityEngine ;
1011using UnityEngine . UI ;
1112
@@ -24,9 +25,15 @@ public class JCS_TextSliderDisplay : JCS_TextObject
2425 [ SerializeField ]
2526 private Slider mSlider = null ;
2627
28+ [ Tooltip ( "Place you want to round the decimal." ) ]
29+ [ SerializeField ]
30+ [ Range ( 0 , 15 ) ]
31+ private int mRoundPlace = 2 ;
32+
2733 /* Setter & Getter */
2834
2935 public Slider slider { get { return this . mSlider ; } set { this . mSlider = value ; } }
36+ public int RoundPlace { get { return this . mRoundPlace ; } set { this . mRoundPlace = value ; } }
3037
3138 /* Functions */
3239
@@ -35,7 +42,9 @@ private void Update()
3542 if ( mSlider == null )
3643 return ;
3744
38- this . text = mSlider . value . ToString ( ) ;
45+ double val = Math . Round ( mSlider . value , mRoundPlace ) ;
46+
47+ this . text = val . ToString ( ) ;
3948 }
4049 }
4150}
Original file line number Diff line number Diff line change @@ -723,6 +723,7 @@ MonoBehaviour:
723723 mTextContainer : {fileID: 1842546916}
724724 mTextMesh : {fileID: 0}
725725 mSlider : {fileID: 1408916069}
726+ mRoundPlace : 2
726727--- !u!1 &2002942730
727728GameObject :
728729 m_ObjectHideFlags : 0
Original file line number Diff line number Diff line change @@ -30,10 +30,10 @@ EditorUserSettings:
3030 value : 0007035056540f095d5c5f7113205d4445154e7878797435742d1c31b5b66239
3131 flags : 0
3232 RecentlyUsedSceneGuid-8 :
33- value : 530857545707085d5e565c73437a0644444f407e7d2b77602f7f1f30b0e5633e
33+ value : 510901525301510b5a59597b417607444f1619722f2b70607e7b4f37e0e46c3b
3434 flags : 0
3535 RecentlyUsedSceneGuid-9 :
36- value : 510901525301510b5a59597b417607444f1619722f2b70607e7b4f37e0e46c3b
36+ value : 530857545707085d5e565c73437a0644444f407e7d2b77602f7f1f30b0e5633e
3737 flags : 0
3838 RecentlyUsedScenePath-0 :
3939 value : 22424703114646712e3d392c1937465f25141d24293b691a0e1a2212f2f03831e1e622e0e8341c303611ea0f0d331433f31e0c45e305031f08
Original file line number Diff line number Diff line change 33Text that display slider's value.
44
55## Variables
6+
7+ | Name | Description |
8+ | :------------| :---------------------------------------------------|
9+ | mSlider | To update the text along with this slider's value. |
10+ | mRoundPlace | Place you want to round the decimal. |
You can’t perform that action at this time.
0 commit comments