File tree Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,14 @@ void Update () {
8282 }
8383 system . OnUpdate ( ) ;
8484 }
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+ }
8593 }
8694
8795#if ECS_PHYSICS || ECS_ALL
Original file line number Diff line number Diff line change @@ -13,6 +13,17 @@ public interface IService {
1313 /// </summary>
1414 void OnInitialized ( ) ;
1515
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+
1627 /// <summary>
1728 // Method invoked when the service is drawing the gizmos, will be called
1829 // every gizmos draw call.
Original file line number Diff line number Diff line change @@ -49,6 +49,11 @@ public virtual void OnInitialize () { }
4949 /// </summary>
5050 public virtual void OnInitialized ( ) { }
5151
52+ /// <summary>
53+ /// Method invoked when the service updates, will be called every frame.
54+ /// </summary>
55+ public virtual void OnUpdate ( ) { }
56+
5257 /// <summary>
5358 /// Method invoked when the service is drawing the gizmos, will be called
5459 /// every gizmos draw call.
@@ -67,6 +72,12 @@ public virtual void OnDrawGui () { }
6772 /// </summary>
6873 public virtual void OnWillDestroy ( ) { }
6974
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+
7081 /// <summary>
7182 /// Starts a coroutine on this service.
7283 /// </summary>
You can’t perform that action at this time.
0 commit comments