TMPro_EventManager.cs
5.21 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
using UnityEngine;
using System.Collections.Generic;
namespace TMPro
{
public enum Compute_DistanceTransform_EventTypes { Processing, Completed };
public static class TMPro_EventManager
{
public static readonly FastAction<object, Compute_DT_EventArgs> COMPUTE_DT_EVENT = new FastAction<object, Compute_DT_EventArgs>();
// Event & Delegate used to notify TextMesh Pro objects that Material properties have been changed.
public static readonly FastAction<bool, Material> MATERIAL_PROPERTY_EVENT = new FastAction<bool, Material>();
public static readonly FastAction<bool, TMP_FontAsset> FONT_PROPERTY_EVENT = new FastAction<bool, TMP_FontAsset>();
public static readonly FastAction<bool, Object> SPRITE_ASSET_PROPERTY_EVENT = new FastAction<bool, Object>();
public static readonly FastAction<bool, TextMeshPro> TEXTMESHPRO_PROPERTY_EVENT = new FastAction<bool, TextMeshPro>();
public static readonly FastAction<GameObject, Material, Material> DRAG_AND_DROP_MATERIAL_EVENT = new FastAction<GameObject, Material, Material>();
public static readonly FastAction<bool> TEXT_STYLE_PROPERTY_EVENT = new FastAction<bool>();
public static readonly FastAction<TMP_ColorGradient> COLOR_GRADIENT_PROPERTY_EVENT = new FastAction<TMP_ColorGradient>();
public static readonly FastAction TMP_SETTINGS_PROPERTY_EVENT = new FastAction();
public static readonly FastAction RESOURCE_LOAD_EVENT = new FastAction();
public static readonly FastAction<bool, TextMeshProUGUI> TEXTMESHPRO_UGUI_PROPERTY_EVENT = new FastAction<bool, TextMeshProUGUI>();
public static readonly FastAction OnPreRenderObject_Event = new FastAction();
public static readonly FastAction<Object> TEXT_CHANGED_EVENT = new FastAction<Object>();
//public static readonly FastAction WILL_RENDER_CANVASES = new FastAction();
//static TMPro_EventManager()
//{
// // Register to the willRenderCanvases callback once
// // then the WILL_RENDER_CANVASES FastAction will handle the rest
// Canvas.willRenderCanvases += WILL_RENDER_CANVASES.Call;
//}
public static void ON_PRE_RENDER_OBJECT_CHANGED()
{
OnPreRenderObject_Event.Call();
}
public static void ON_MATERIAL_PROPERTY_CHANGED(bool isChanged, Material mat)
{
MATERIAL_PROPERTY_EVENT.Call(isChanged, mat);
}
public static void ON_FONT_PROPERTY_CHANGED(bool isChanged, TMP_FontAsset font)
{
FONT_PROPERTY_EVENT.Call(isChanged, font);
}
public static void ON_SPRITE_ASSET_PROPERTY_CHANGED(bool isChanged, Object obj)
{
SPRITE_ASSET_PROPERTY_EVENT.Call(isChanged, obj);
}
public static void ON_TEXTMESHPRO_PROPERTY_CHANGED(bool isChanged, TextMeshPro obj)
{
TEXTMESHPRO_PROPERTY_EVENT.Call(isChanged, obj);
}
public static void ON_DRAG_AND_DROP_MATERIAL_CHANGED(GameObject sender, Material currentMaterial, Material newMaterial)
{
DRAG_AND_DROP_MATERIAL_EVENT.Call(sender, currentMaterial, newMaterial);
}
public static void ON_TEXT_STYLE_PROPERTY_CHANGED(bool isChanged)
{
TEXT_STYLE_PROPERTY_EVENT.Call(isChanged);
}
public static void ON_COLOR_GRAIDENT_PROPERTY_CHANGED(TMP_ColorGradient gradient)
{
COLOR_GRADIENT_PROPERTY_EVENT.Call(gradient);
}
public static void ON_TEXT_CHANGED(Object obj)
{
TEXT_CHANGED_EVENT.Call(obj);
}
public static void ON_TMP_SETTINGS_CHANGED()
{
TMP_SETTINGS_PROPERTY_EVENT.Call();
}
public static void ON_RESOURCES_LOADED()
{
RESOURCE_LOAD_EVENT.Call();
}
public static void ON_TEXTMESHPRO_UGUI_PROPERTY_CHANGED(bool isChanged, TextMeshProUGUI obj)
{
TEXTMESHPRO_UGUI_PROPERTY_EVENT.Call(isChanged, obj);
}
//public static void ON_BASE_MATERIAL_CHANGED(Material mat)
//{
// BASE_MATERIAL_EVENT.Call(mat);
//}
//public static void ON_PROGRESSBAR_UPDATE(Progress_Bar_EventTypes event_type, Progress_Bar_EventArgs eventArgs)
//{
// if (PROGRESS_BAR_EVENT != null)
// PROGRESS_BAR_EVENT(event_type, eventArgs);
//}
public static void ON_COMPUTE_DT_EVENT(object Sender, Compute_DT_EventArgs e)
{
COMPUTE_DT_EVENT.Call(Sender, e);
}
}
public class Compute_DT_EventArgs
{
public Compute_DistanceTransform_EventTypes EventType;
public float ProgressPercentage;
public Color[] Colors;
public Compute_DT_EventArgs(Compute_DistanceTransform_EventTypes type, float progress)
{
EventType = type;
ProgressPercentage = progress;
}
public Compute_DT_EventArgs(Compute_DistanceTransform_EventTypes type, Color[] colors)
{
EventType = type;
Colors = colors;
}
}
}