File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
com.unity.netcode.gameobjects/Runtime/Core Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -2556,8 +2556,12 @@ internal void InvokeBehaviourNetworkSpawn()
25562556 {
25572557 NetworkManager . SpawnManager . UpdateOwnershipTable ( this , OwnerClientId ) ;
25582558
2559- // Always invoke all internal network spawn methods on each child NetworkBehaviour
2559+ // Always invoke all InternalOnNetworkSpawn methods on each child NetworkBehaviour
25602560 // ** before ** invoking OnNetworkSpawn.
2561+ // This assures all NetworkVariables and RPC related tables have been initialized
2562+ // prior to invoking OnNetworkSpawn so cross NetworkBehaviour:
2563+ // - accessing of NetworkVariables will work correctly.
2564+ // - invocation of RPCs will work properly (and not throw exception under certain scenarios)
25612565 foreach ( var childBehaviour in ChildNetworkBehaviours )
25622566 {
25632567 if ( ! childBehaviour . gameObject . activeInHierarchy )
@@ -2568,7 +2572,7 @@ internal void InvokeBehaviourNetworkSpawn()
25682572 childBehaviour . InternalOnNetworkSpawn ( ) ;
25692573 }
25702574
2571- // Invoke OnNetworkSpawn on each child NetworkBehaviour
2575+ // After initialization, we can then invoke OnNetworkSpawn on each child NetworkBehaviour.
25722576 foreach ( var childBehaviour in ChildNetworkBehaviours )
25732577 {
25742578 if ( ! childBehaviour . gameObject . activeInHierarchy )
@@ -2591,7 +2595,6 @@ internal void InvokeBehaviourNetworkPostSpawn()
25912595 }
25922596 }
25932597
2594-
25952598 internal void InternalNetworkSessionSynchronized ( )
25962599 {
25972600 for ( int i = 0 ; i < ChildNetworkBehaviours . Count ; i ++ )
You can’t perform that action at this time.
0 commit comments