File tree 3 files changed +30
-0
lines changed
3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,14 @@ void Update () {
82
82
}
83
83
system . OnUpdate ( ) ;
84
84
}
85
+ // Invoking update method on each service.
86
+ for ( var serviceIndex = 0 ; serviceIndex < services . Count ; serviceIndex ++ ) {
87
+ var service = services [ serviceIndex ] ;
88
+ if ( ! service . ShouldUpdate ( ) ) {
89
+ continue ;
90
+ }
91
+ service . OnUpdate ( ) ;
92
+ }
85
93
}
86
94
87
95
#if ECS_PHYSICS || ECS_ALL
Original file line number Diff line number Diff line change @@ -13,6 +13,17 @@ public interface IService {
13
13
/// </summary>
14
14
void OnInitialized ( ) ;
15
15
16
+ /// <summary>
17
+ /// Method invoked when the service updates, will be called every frame.
18
+ /// </summary>
19
+ void OnUpdate ( ) { }
20
+
21
+ /// <summary>
22
+ // Method invoked before the system will update, return whether this system
23
+ // should update. will be called every frame.
24
+ /// </summary>
25
+ bool ShouldUpdate ( ) ;
26
+
16
27
/// <summary>
17
28
// Method invoked when the service is drawing the gizmos, will be called
18
29
// every gizmos draw call.
Original file line number Diff line number Diff line change @@ -49,6 +49,11 @@ public virtual void OnInitialize () { }
49
49
/// </summary>
50
50
public virtual void OnInitialized ( ) { }
51
51
52
+ /// <summary>
53
+ /// Method invoked when the service updates, will be called every frame.
54
+ /// </summary>
55
+ public virtual void OnUpdate ( ) { }
56
+
52
57
/// <summary>
53
58
/// Method invoked when the service is drawing the gizmos, will be called
54
59
/// every gizmos draw call.
@@ -67,6 +72,12 @@ public virtual void OnDrawGui () { }
67
72
/// </summary>
68
73
public virtual void OnWillDestroy ( ) { }
69
74
75
+ /// <summary>
76
+ /// Method invoked before the system will update, return whether this system
77
+ /// should update. will be called every frame.
78
+ /// </summary>
79
+ public virtual bool ShouldUpdate ( ) { return true ; }
80
+
70
81
/// <summary>
71
82
/// Starts a coroutine on this service.
72
83
/// </summary>
You can’t perform that action at this time.
0 commit comments