File tree Expand file tree Collapse file tree 3 files changed +48
-14
lines changed Expand file tree Collapse file tree 3 files changed +48
-14
lines changed Original file line number Diff line number Diff line change 16
16
17
17
namespace Wanderer . GameFramework
18
18
{
19
- public sealed class UIManager : GameFrameworkModule
19
+ public sealed class UIManager : GameFrameworkModule , IUpdate
20
20
{
21
21
//事件管理器
22
22
private EventManager _event ;
@@ -284,6 +284,7 @@ private UIView GetUIView(IUIContext uiContext)
284
284
if ( uiView == null )
285
285
return null ;
286
286
_allUIView [ uiContext ] = uiView ;
287
+ uiView . OnInit ( uiContext ) ;
287
288
return uiView ;
288
289
}
289
290
uiView . gameObject . SetActive ( true ) ;
@@ -303,6 +304,18 @@ public override void OnClose()
303
304
}
304
305
_allUIView . Clear ( ) ;
305
306
}
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
+ }
308
321
}
Original file line number Diff line number Diff line change @@ -19,6 +19,18 @@ public abstract class UIView : MonoBehaviour
19
19
//外部的回调
20
20
protected Action < string > _callBack ;
21
21
/// <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>
22
34
/// 打开界面
23
35
/// </summary>
24
36
/// <param name="parameters">不确定参数</param>
@@ -43,30 +55,24 @@ public virtual void OnPause(IUIContext uiConext)
43
55
/// </summary>
44
56
public virtual void OnResume ( IUIContext uiConext )
45
57
{ }
46
-
47
58
/// <summary>
48
59
/// 动画开始
49
60
/// </summary>
50
61
/// <param name="uiAnim"></param>
51
62
public virtual void OnAnimationStart ( IUIAnimation uiAnim )
52
- {
53
- }
63
+ { }
54
64
/// <summary>
55
65
/// 动画结束
56
66
/// </summary>
57
67
/// <param name="uiAnim"></param>
58
68
public virtual void OnAnimationComplete ( IUIAnimation uiAnim )
59
- {
60
- }
61
-
69
+ { }
62
70
/// <summary>
63
71
/// 设置深度
64
72
/// </summary>
65
73
/// <param name="depth"></param>
66
74
public virtual void SetDepth ( int depth )
67
- {
68
- }
69
-
75
+ { }
70
76
/// <summary>
71
77
/// 调用回调
72
78
/// </summary>
Original file line number Diff line number Diff line change @@ -19,8 +19,23 @@ protected virtual void Awake()
19
19
}
20
20
}
21
21
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 ) ;
24
39
}
25
40
26
41
/// <summary>
You can’t perform that action at this time.
0 commit comments