-
Notifications
You must be signed in to change notification settings - Fork 96
/
SCAN_TextMeshPro.cs
70 lines (56 loc) · 1.6 KB
/
SCAN_TextMeshPro.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#region license
/*
* [Scientific Committee on Advanced Navigation]
* S.C.A.N. Satellite
*
* SCAN_TextMeshPro - An extension of TextMeshProUGUI for updating certain elements of the text
*
* Copyright (c)2014 David Grandy <david.grandy@gmail.com>;
* Copyright (c)2014 technogeeky <technogeeky@gmail.com>;
* Copyright (c)2014 (Your Name Here) <your email here>; see LICENSE.txt for licensing details.
*/
#endregion
using SCANsat.Unity;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
using TMPro;
namespace SCANsat.SCAN_Unity
{
public class SCAN_TextMeshPro : TextMeshProUGUI
{
private TextHandler _handler;
new private void Awake()
{
m_isAlignmentEnumConverted = true;
base.Awake();
_handler = GetComponent<TextHandler>();
if (_handler == null)
return;
_handler.SetNormalColor(color);
_handler.OnColorUpdate.AddListener(new UnityAction<Color>(UpdateColor));
_handler.OnTextUpdate.AddListener(new UnityAction<string>(UpdateText));
_handler.OnFontChange.AddListener(new UnityAction<int>(UpdateFontSize));
}
public void Setup(TextHandler h)
{
_handler = h;
_handler.OnColorUpdate.AddListener(new UnityAction<Color>(UpdateColor));
_handler.OnTextUpdate.AddListener(new UnityAction<string>(UpdateText));
_handler.OnFontChange.AddListener(new UnityAction<int>(UpdateFontSize));
}
private void UpdateColor(Color c)
{
color = c;
}
private void UpdateText(string t)
{
text = t;
_handler.PreferredSize = new Vector2(preferredWidth, preferredHeight);
}
private void UpdateFontSize(int i)
{
fontSize += i;
}
}
}