-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(TextSlider): Add text slider component
- Loading branch information
Showing
9 changed files
with
1,008 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* $File: JCS_TextObject.cs $ | ||
* $Date: 2022-09-04 01:14:38 $ | ||
* $Revision: $ | ||
* $Creator: Jen-Chieh Shen $ | ||
* $Notice: See LICENSE.txt for modification and distribution information | ||
* Copyright © 2022 by Shen, Jen-Chieh $ | ||
*/ | ||
|
||
/* NOTE: If you are using `TextMesh Pro` uncomment this line. | ||
*/ | ||
#define TMP_PRO | ||
|
||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
#if TMP_PRO | ||
using TMPro; | ||
#endif | ||
|
||
namespace JCSUnity | ||
{ | ||
/// <summary> | ||
/// Holds all type of UI text objects. | ||
/// </summary> | ||
public class JCS_TextObject : MonoBehaviour | ||
{ | ||
/* Variables */ | ||
|
||
[Header("** Initialize Variables (JCS_TextObject) **")] | ||
|
||
[Tooltip("Target text renderer.")] | ||
[SerializeField] | ||
private Text mTextContainer = null; | ||
|
||
#if TMP_PRO | ||
[Tooltip("Target text renderer. (TMP)")] | ||
[SerializeField] | ||
private TextMeshPro mTextMesh = null; | ||
#endif | ||
|
||
/* Setter & Getter */ | ||
|
||
public Text TextContainer { get { return this.mTextContainer; } set { this.mTextContainer = value; } } | ||
#if TMP_PRO | ||
public TextMeshPro TextMesh { get { return this.mTextMesh; } set { this.mTextMesh = value; } } | ||
#endif | ||
|
||
/* Functions */ | ||
|
||
public string text | ||
{ | ||
get { return this.mTextContainer.text; } // just return one of them | ||
set | ||
{ | ||
if (this.mTextContainer) this.mTextContainer.text = value; | ||
if (this.mTextMesh) this.mTextMesh.text = value; | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* $File: JCS_TextSliderDisplay.cs $ | ||
* $Date: 2022-09-04 01:10:40 $ | ||
* $Revision: $ | ||
* $Creator: Jen-Chieh Shen $ | ||
* $Notice: See LICENSE.txt for modification and distribution information | ||
* Copyright © 2022 by Shen, Jen-Chieh $ | ||
*/ | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
namespace JCSUnity | ||
{ | ||
/// <summary> | ||
/// Text that display slider's value. | ||
/// </summary> | ||
public class JCS_TextSliderDisplay : JCS_TextObject | ||
{ | ||
/* Variables */ | ||
|
||
[Header("** Initialize Variables (JCS_TextSliderDisplay) **")] | ||
|
||
[Tooltip("To update the text along with this slider's value.")] | ||
[SerializeField] | ||
private Slider mSlider = null; | ||
|
||
/* Setter & Getter */ | ||
|
||
/* Functions */ | ||
|
||
private void Update() | ||
{ | ||
if (mSlider == null) | ||
return; | ||
|
||
this.text = mSlider.value.ToString(); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Assets/JCSUnity/Scripts/UI/Text/JCS_TextSliderDisplay.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.