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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
|
using UILib;
using UnityEngine;
using System.Collections.Generic;
using System.Collections;
using XUtliPoolLib;
public class XUITool : MonoBehaviour, IXUITool
{
public static XUITool Instance { get { return s_instance; } }
private Dictionary<int, uint> _TweenFadeInGroupDelayNum = new Dictionary<int, uint>();
private IXGameUI m_gameui = null;
private GameObject m_preloadBillboard = null;
private GameObject m_preloadTitle = null;
public IXGameUI XGameUI
{
get
{
if (m_gameui == null)
{
m_gameui = XInterfaceMgr.singleton.GetInterface<IXGameUI>(XCommon.singleton.XHash("XGameUI"));
}
return m_gameui;
}
}
public Camera GetUICamera()
{
return UICamera.currentCamera;
}
public void SetActive(GameObject obj, bool state)
{
NGUITools.SetActive(obj, state);
}
public void SetLayer(GameObject go, int layer)
{
go.layer = layer;
Transform t = go.transform;
for (int i=0, imax = t.childCount; i<imax; ++i)
{
Transform child = t.GetChild(i);
SetLayer(child.gameObject, layer);
}
}
public void SetUIDepthDelta(GameObject go, int delta)
{
XUISprite[] sp = go.GetComponentsInChildren<XUISprite>();
XUILabel[] la = go.GetComponentsInChildren<XUILabel>();
XUITexture[] te = go.GetComponentsInChildren<XUITexture>();
for(int i = 0; i < sp.Length; ++i)
{
sp[i].spriteDepth += delta;
}
for(int i = 0; i < la.Length; ++i)
{
la[i].spriteDepth += delta;
}
for(int i = 0; i < te.Length; ++i)
{
te[i].spriteDepth += delta;
}
}
public void SetUIEventFallThrough(GameObject obj)
{
UICamera.fallThrough = obj;
}
public void SetUIGenericEventHandle(GameObject obj)
{
UICamera.genericEventHandler = obj;
}
public void ShowTooltip(string str)
{
UITooltip.ShowText(str);
}
public void RegisterLoadUIAsynEventHandler(LoadUIAsynEventHandler eventHandler)
{
m_loadUIAsynEventHandler = eventHandler;
}
public void LoadResAsyn(string strFile, LoadUIFinishedEventHandler eventHandler)
{
if (null != m_loadUIAsynEventHandler)
{
//m_loadUIAsynEventHandler(strFile, eventHandler);
}
else
{
Debug.LogError("null == m_loadUIAsynEventHandler");
}
}
public void SetCursor(string strSpriteName)
{
//UICursor.Set(strSpriteName);
}
public void SetCursor(string strSprite, string strAtlas)
{
// if (null != UICursor.Instance)
// {
// }
}
public void PlayAnim(Animation anim, string strClipName, AnimFinishedEventHandler eventHandler)
{
if (null == anim || null == strClipName || strClipName.Length == 0)
{
eventHandler();
return;
}
//ActiveAnimation.Play(anim, strClipName, Direction.Forward, EnableCondition.DoNothing, DisableCondition.DoNotDisable, eventHandler);
}
private void Awake()
{
s_instance = this;
}
public void MarkParentAsChanged(GameObject go)
{
NGUITools.MarkParentAsChanged(go);
}
public void HideGameObject(GameObject go)
{
NGUITools.ParentPanelChanged(go, XUICommon.singleton.m_inVisiablePanel);
}
public void ShowGameObject(GameObject go, IXUIPanel panel)
{
XUIPanel p = panel as XUIPanel;
if (p != null)
NGUITools.ParentPanelChanged(go, p.UIComponent as UIPanel);
else
NGUITools.MarkParentAsChanged(go);
}
public void ChangePanel(GameObject go, IUIRect parent, IXUIPanel panel)
{
XUIPanel p = panel as XUIPanel;
UIRect pp = parent as UIRect;
if (p != null)
NGUITools.ParentPanelChanged(go, pp, p.UIComponent as UIPanel);
}
public void ChangePanel(GameObject go, IUIRect parent, IUIPanel panel)
{
UIPanel p = panel as UIPanel;
UIRect pp = parent as UIRect;
if (p != null)
NGUITools.ParentPanelChanged(go, pp, p);
}
public string GetLocalizedStr(string key)
{
return Localization.Get(key);
}
void IXUITool.Destroy(UnityEngine.Object obj)
{
NGUITools.Destroy(obj);
}
private LoadUIAsynEventHandler m_loadUIAsynEventHandler = null;
//private string m_spriteNameForCusorCached = "";
static XUITool s_instance = null;
public Vector2 CalculatePrintedSize(string text)
{
return NGUIText.CalculatePrintedSize(text);
}
public void ReleaseAllDrawCall()
{
UIDrawCall.ReleaseInactive();
}
bool delayDealWith = false;
void LateUpdate()
{
if(delayDealWith)
{
delayDealWith = false;
ClearFadeInGroupDict();
}
}
public bool GetTweenFadeInDelayByGroup(int group, float interval, int max, out float addDelay)
{
addDelay = 0f;
if(_TweenFadeInGroupDelayNum.Count == 0)
{
//StartCoroutine(ClearFadeInGroupDict());
delayDealWith = true;
}
uint num;
if (!_TweenFadeInGroupDelayNum.TryGetValue(group, out num))
{
_TweenFadeInGroupDelayNum[group] = 0;
num = 0;
addDelay = 0;
return true;
}
else
{
_TweenFadeInGroupDelayNum[group] = num + 1;
num++;
if (num >= max)
return false;
addDelay = num * interval;
return true;
}
}
void ClearFadeInGroupDict()
{
//yield return new WaitForEndOfFrame();
_TweenFadeInGroupDelayNum.Clear();
}
public void ResetGroupDelay(int group)
{
if (_TweenFadeInGroupDelayNum.ContainsKey(group))
_TweenFadeInGroupDelayNum.Remove(group);
}
public void SetRootPanelUpdateFreq(int count)
{
XUICommon.singleton.SetRootPanelUpdateFreq(count);
}
public void PreLoad(bool load)
{
if(load)
{
if (m_preloadBillboard == null)
m_preloadBillboard = XResourceLoaderMgr.singleton.GetSharedResource<GameObject>("atlas/UI/common/Billboard", ".prefab");
if (m_preloadTitle == null)
m_preloadTitle = XResourceLoaderMgr.singleton.GetSharedResource<GameObject>("atlas/UI/common/Title", ".prefab");
}
else
{
XResourceLoaderMgr.SafeDestroyShareResource("atlas/UI/common/Billboard", ref m_preloadBillboard);
XResourceLoaderMgr.SafeDestroyShareResource("atlas/UI/common/Title", ref m_preloadTitle);
}
}
public void EnableUILoadingUpdate(bool enable)
{
NGUITools.mEnableLoadingUpdate = enable;
}
public void SetUIOptOption(bool globalMerge,bool selectMerge,bool lowDeviceMerge)
{
//disable global ui merge if we are using low device
if ( XUpdater.XUpdater.singleton.XPlatform.GetQualityLevel () == 0 && !lowDeviceMerge)
{
UIPanel.GlobalUseMerge = false;
UIPanel.SelectUseMerge = selectMerge;
} else {
UIPanel.GlobalUseMerge = globalMerge;
UIPanel.SelectUseMerge = selectMerge;
}
}
}
|