HKI Core
HKI Core
UI
UIValueText.cs
Go to the documentation of this file.
1
using
UnityEngine
;
2
using
UnityEngine
.UI;
3
using
HKI
.
Core
.
Variables
;
4
5
namespace
HKI
.Core.UI
6
{
10
[AddComponentMenu(
"HKI/UI/UIValueText"
)]
11
[DisallowMultipleComponent]
12
public
class
UIValueText
: MonoBehaviour
13
{
14
// Public variables
15
[Header(
"General Properties"
)]
16
[SerializeField]
HKIVar
Variable = null;
17
18
// Private variables
19
TMProAndUGUITextAccessor
valueText = null;
20
21
// Awake function
22
void
Awake
()
23
{
24
if
(Variable == null)
25
{
26
Debug.LogError(
"(UIValueText)"
+ name +
" there isn't a variable attached to this value text!"
);
27
return
;
28
}
29
30
valueText =
new
TMProAndUGUITextAccessor
(gameObject);
31
}
32
33
// OnEnable function
34
void
OnEnable
()
35
{
36
UpdateText();
37
38
if
(Variable != null)
39
Variable.
OnValueChanged
+= UpdateText;
40
}
41
42
// OnDisable function
43
void
OnDisable
()
44
{
45
if
(Variable != null)
46
Variable.
OnValueChanged
-= UpdateText;
47
}
48
49
// Interface function
50
public
void
UpdateText
()
51
{
52
if
(Variable != null)
53
valueText.
ChangeText
(Variable.ToString());
54
}
55
}
56
}
HKI.Core.UI.UIValueText.OnDisable
void OnDisable()
Definition:
UIValueText.cs:43
HKI.Core
HKI.Core.Variables.HKIVar.OnValueChanged
System.Action OnValueChanged
Definition:
HKIVar.cs:15
HKI.Core.UI.UIValueText.UpdateText
void UpdateText()
Definition:
UIValueText.cs:50
HKI.Core.Variables
HKI.Core.UI.UIValueText
This MonoBehaviour set the text of an Unity UIText or a TextMeshPro text component to the value of a ...
Definition:
UIValueText.cs:12
HKI.Core.UI.TMProAndUGUITextAccessor.ChangeText
void ChangeText(string text)
Definition:
TMProAndUGUITextAccessor.cs:51
HKI.Core.UI.UIValueText.OnEnable
void OnEnable()
Definition:
UIValueText.cs:34
HKI.Core.Variables.HKIVar
This abstract class of a ScriptableObject is provides child classes with on value changed callback ca...
Definition:
HKIVar.cs:12
HKI.Core.UI.TMProAndUGUITextAccessor
This class allows the use of the standard Unity UI Text component and the TextMeshPro component witho...
Definition:
TMProAndUGUITextAccessor.cs:12
HKI.Core.UI.UIValueText.Awake
void Awake()
Definition:
UIValueText.cs:22
UnityEngine
HKI
Generated by
1.8.13