Skip to content

Commit c6e27e8

Browse files
author
wanderer
committed
增加UIManager的OnInit, OnUpdate
1 parent ead634b commit c6e27e8

File tree

3 files changed

+48
-14
lines changed

3 files changed

+48
-14
lines changed

GameFramework/Runtime/UI/UIManager.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
namespace Wanderer.GameFramework
1818
{
19-
public sealed class UIManager : GameFrameworkModule
19+
public sealed class UIManager : GameFrameworkModule,IUpdate
2020
{
2121
//事件管理器
2222
private EventManager _event;
@@ -284,6 +284,7 @@ private UIView GetUIView(IUIContext uiContext)
284284
if (uiView == null)
285285
return null;
286286
_allUIView[uiContext] = uiView;
287+
uiView.OnInit(uiContext);
287288
return uiView;
288289
}
289290
uiView.gameObject.SetActive(true);
@@ -303,6 +304,18 @@ public override void OnClose()
303304
}
304305
_allUIView.Clear();
305306
}
306-
#endregion
307-
}
307+
308+
//更新函数
309+
public void OnUpdate()
310+
{
311+
for (int i = 0; i < _activeUIContextList.Count; i++)
312+
{
313+
if (_allUIView.TryGetValue(_activeUIContextList[i], out UIView uiView))
314+
{
315+
uiView.OnUpdate(_activeUIContextList[i], Time.deltaTime);
316+
}
317+
}
318+
}
319+
#endregion
320+
}
308321
}

GameFramework/Runtime/UI/UIView.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ public abstract class UIView : MonoBehaviour
1919
//外部的回调
2020
protected Action<string> _callBack;
2121
/// <summary>
22+
/// 初始化
23+
/// </summary>
24+
/// <param name="uiContext"></param>
25+
public virtual void OnInit(IUIContext uiContext)
26+
{ }
27+
/// <summary>
28+
/// 更新界面
29+
/// </summary>
30+
/// <param name="uiContext"></param>
31+
public virtual void OnUpdate(IUIContext uiContext,float deltaTime)
32+
{ }
33+
/// <summary>
2234
/// 打开界面
2335
/// </summary>
2436
/// <param name="parameters">不确定参数</param>
@@ -43,30 +55,24 @@ public virtual void OnPause(IUIContext uiConext)
4355
/// </summary>
4456
public virtual void OnResume(IUIContext uiConext)
4557
{ }
46-
4758
/// <summary>
4859
/// 动画开始
4960
/// </summary>
5061
/// <param name="uiAnim"></param>
5162
public virtual void OnAnimationStart(IUIAnimation uiAnim)
52-
{
53-
}
63+
{ }
5464
/// <summary>
5565
/// 动画结束
5666
/// </summary>
5767
/// <param name="uiAnim"></param>
5868
public virtual void OnAnimationComplete(IUIAnimation uiAnim)
59-
{
60-
}
61-
69+
{ }
6270
/// <summary>
6371
/// 设置深度
6472
/// </summary>
6573
/// <param name="depth"></param>
6674
public virtual void SetDepth(int depth)
67-
{
68-
}
69-
75+
{}
7076
/// <summary>
7177
/// 调用回调
7278
/// </summary>

UI/UGUIView.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,23 @@ protected virtual void Awake()
1919
}
2020
}
2121

22-
protected virtual void Update()
23-
{
22+
/// <summary>
23+
/// 初始化
24+
/// </summary>
25+
/// <param name="uiContext"></param>
26+
public override void OnInit(IUIContext uiContext)
27+
{
28+
base.OnInit(uiContext);
29+
}
30+
31+
32+
/// <summary>
33+
/// 更新界面
34+
/// </summary>
35+
/// <param name="uiContext"></param>
36+
public override void OnUpdate(IUIContext uiContext, float deltaTime)
37+
{
38+
base.OnUpdate(uiContext, deltaTime);
2439
}
2540

2641
/// <summary>

0 commit comments

Comments
 (0)