@@ -357,9 +357,8 @@ internal bool HasParentNetworkObject(Transform transform)
357357 }
358358
359359 /// <summary>
360- /// Gets the NetworkManager that owns this NetworkObject instance
360+ /// Gets the NetworkManager that owns this NetworkObject instance.
361361 /// </summary>
362- // TODO use the correct one, here are we sure it is spawned? if it is, use NetworkManager
363362 public NetworkManager NetworkManager = NetworkManager . Singleton ;
364363
365364 /// <summary>
@@ -1125,7 +1124,7 @@ private bool InternalHasAuthority()
11251124 /// <summary>
11261125 /// The NetworkManager that owns this NetworkObject.
11271126 /// This property controls where this NetworkObject belongs.
1128- /// This property is null by default currently, which means that the above NetworkManager getter will return the Singleton .
1127+ /// This property is null by default currently.
11291128 /// In the future this is the path where alternative NetworkManagers should be injected for running multi NetworkManagers
11301129 /// </summary>
11311130 internal NetworkManager NetworkManagerOwner ;
@@ -2233,7 +2232,7 @@ public bool TrySetParent(NetworkObject parent, bool worldPositionStays = true)
22332232 return false ;
22342233 }
22352234
2236- if ( NetworkManager == null || ! NetworkManager . IsListening )
2235+ if ( ! NetworkManager . IsListening )
22372236 {
22382237 return false ;
22392238 }
@@ -2254,7 +2253,7 @@ public bool TrySetParent(NetworkObject parent, bool worldPositionStays = true)
22542253
22552254 internal bool InternalTrySetParent ( NetworkObject parent , bool worldPositionStays = true )
22562255 {
2257- if ( parent != null && ( IsSpawned ^ parent . IsSpawned ) && NetworkManager != null && ! NetworkManager . ShutdownInProgress )
2256+ if ( parent != null && ( IsSpawned ^ parent . IsSpawned ) && ! NetworkManager . ShutdownInProgress )
22582257 {
22592258 if ( NetworkManager . LogLevel <= LogLevel . Developer )
22602259 {
@@ -2292,7 +2291,7 @@ private void OnTransformParentChanged()
22922291 return ;
22932292 }
22942293
2295- if ( NetworkManager == null || ! NetworkManager . IsListening )
2294+ if ( ! NetworkManager . IsListening )
22962295 {
22972296 // DANGO-TODO: Review as to whether we want to provide a better way to handle changing parenting of objects when the
22982297 // object is not spawned. Really, we shouldn't care about these types of changes.
@@ -3422,9 +3421,10 @@ internal void SubscribeToActiveSceneForSynch()
34223421 /// </summary>
34233422 private void CurrentlyActiveSceneChanged ( Scene current , Scene next )
34243423 {
3424+ // TODO should we remove NetworkManager null check here?
34253425 // Early exit if there is no NetworkManager assigned, the NetworkManager is shutting down, the NetworkObject
34263426 // is not spawned, or an in-scene placed NetworkObject
3427- if ( NetworkManager == null || NetworkManager . ShutdownInProgress || ! IsSpawned || IsSceneObject != false )
3427+ if ( NetworkManager . ShutdownInProgress || ! IsSpawned || IsSceneObject != false )
34283428 {
34293429 return ;
34303430 }
@@ -3523,10 +3523,11 @@ private void Awake()
35233523 /// </remarks>
35243524 internal bool UpdateForSceneChanges ( )
35253525 {
3526+ // TODO should we remove NetworkManager null check here?
35263527 // Early exit if SceneMigrationSynchronization is disabled, there is no NetworkManager assigned,
35273528 // the NetworkManager is shutting down, the NetworkObject is not spawned, it is an in-scene placed
35283529 // NetworkObject, or the GameObject's current scene handle is the same as the SceneOriginHandle
3529- if ( ! SceneMigrationSynchronization || ! IsSpawned || NetworkManager == null || NetworkManager . ShutdownInProgress ||
3530+ if ( ! SceneMigrationSynchronization || ! IsSpawned || NetworkManager . ShutdownInProgress ||
35303531 ! NetworkManager . NetworkConfig . EnableSceneManagement || IsSceneObject != false || ! gameObject )
35313532 {
35323533 // Stop checking for a scene migration
@@ -3598,7 +3599,7 @@ internal void OnNetworkBehaviourDestroyed(NetworkBehaviour networkBehaviour)
35983599 {
35993600 if ( networkBehaviour . IsSpawned && IsSpawned )
36003601 {
3601- if ( NetworkManager ? . LogLevel == LogLevel . Developer )
3602+ if ( NetworkManager . LogLevel == LogLevel . Developer )
36023603 {
36033604 NetworkLog . LogWarning ( $ "{ nameof ( NetworkBehaviour ) } -{ networkBehaviour . name } is being destroyed while { nameof ( NetworkObject ) } -{ name } is still spawned! (could break state synchronization)") ;
36043605 }
0 commit comments