@@ -224,6 +224,14 @@ private void Awake()
224
224
this . RegisterNetworkUpdate ( NetworkUpdateStage . FixedUpdate ) ;
225
225
this . RegisterNetworkUpdate ( NetworkUpdateStage . PreUpdate ) ;
226
226
this . RegisterNetworkUpdate ( NetworkUpdateStage . PreLateUpdate ) ;
227
+ this . RegisterNetworkUpdate ( NetworkUpdateStage . PostLateUpdate ) ;
228
+
229
+ // intentionally try to register for 'PreUpdate' stage twice
230
+ // it should be ignored and the instance should not be registered twice
231
+ // otherwise test would fail because it would call 'OnPreUpdate()' twice
232
+ // which would ultimately increment 'netUpdates[idx]' integer twice
233
+ // and cause 'Assert.AreEqual()' to fail the test
234
+ this . RegisterNetworkUpdate ( NetworkUpdateStage . PreUpdate ) ;
227
235
}
228
236
229
237
public void NetworkUpdate ( NetworkUpdateStage updateStage )
@@ -239,6 +247,9 @@ public void NetworkUpdate(NetworkUpdateStage updateStage)
239
247
case NetworkUpdateStage . PreLateUpdate :
240
248
UpdateCallbacks . OnPreLateUpdate ( ) ;
241
249
break ;
250
+ case NetworkUpdateStage . PostLateUpdate :
251
+ UpdateCallbacks . OnPostLateUpdate ( ) ;
252
+ break ;
242
253
}
243
254
}
244
255
@@ -269,7 +280,8 @@ public IEnumerator UpdateStagesMixed()
269
280
const int kNetFixedUpdateIndex = 0 ;
270
281
const int kNetPreUpdateIndex = 1 ;
271
282
const int kNetPreLateUpdateIndex = 2 ;
272
- int [ ] netUpdates = new int [ 3 ] ;
283
+ const int kNetPostLateUpdateIndex = 3 ;
284
+ int [ ] netUpdates = new int [ 4 ] ;
273
285
const int kMonoFixedUpdateIndex = 0 ;
274
286
const int kMonoUpdateIndex = 1 ;
275
287
const int kMonoLateUpdateIndex = 2 ;
@@ -304,6 +316,14 @@ public IEnumerator UpdateStagesMixed()
304
316
netUpdates [ kNetPreLateUpdateIndex ] ++ ;
305
317
Assert . AreEqual ( monoUpdates [ kMonoLateUpdateIndex ] + 1 , netUpdates [ kNetPreLateUpdateIndex ] ) ;
306
318
}
319
+ } ,
320
+ OnPostLateUpdate = ( ) =>
321
+ {
322
+ if ( isTesting )
323
+ {
324
+ netUpdates [ kNetPostLateUpdateIndex ] ++ ;
325
+ Assert . AreEqual ( netUpdates [ kNetPostLateUpdateIndex ] , netUpdates [ kNetPreLateUpdateIndex ] ) ;
326
+ }
307
327
}
308
328
} ;
309
329
gameScript . BehaviourCallbacks = new MonoBehaviourCallbacks
0 commit comments