@@ -1118,7 +1118,7 @@ private bool InternalHasAuthority()
11181118 /// <summary>
11191119 /// The NetworkManager that owns this NetworkObject.
11201120 /// This property controls where this NetworkObject belongs.
1121- /// This property is null by default currently .
1121+ /// This property will be null when the NetworkObject is not spawned .
11221122 /// In the future this is the path where alternative NetworkManagers should be injected for running multi NetworkManagers
11231123 /// </summary>
11241124 internal NetworkManager NetworkManagerOwner ;
@@ -1163,17 +1163,17 @@ private bool InternalHasAuthority()
11631163 /// <summary>
11641164 /// Gets if the object is the personal clients player object
11651165 /// </summary>
1166- public bool IsLocalPlayer => IsPlayerObject && OwnerClientId == NetworkManager . LocalClientId ;
1166+ public bool IsLocalPlayer => IsSpawned && IsPlayerObject && OwnerClientId == NetworkManagerOwner . LocalClientId ;
11671167
11681168 /// <summary>
11691169 /// Gets if the object is owned by the local player or if the object is the local player object
11701170 /// </summary>
1171- public bool IsOwner => OwnerClientId == NetworkManager . LocalClientId ;
1171+ public bool IsOwner => IsSpawned && OwnerClientId == NetworkManager . LocalClientId ;
11721172
11731173 /// <summary>
11741174 /// Gets Whether or not the object is owned by anyone
11751175 /// </summary>
1176- public bool IsOwnedByServer => OwnerClientId == NetworkManager . ServerClientId ;
1176+ public bool IsOwnedByServer => IsSpawned && OwnerClientId == NetworkManager . ServerClientId ;
11771177
11781178 /// <summary>
11791179 /// Gets if the object has yet been spawned across the network
@@ -2275,7 +2275,7 @@ internal bool InternalTrySetParent(NetworkObject parent, bool worldPositionStays
22752275
22762276 private void OnTransformParentChanged ( )
22772277 {
2278- if ( ! AutoObjectParentSync || NetworkManager . ShutdownInProgress )
2278+ if ( ! AutoObjectParentSync )
22792279 {
22802280 return ;
22812281 }
@@ -2285,8 +2285,12 @@ private void OnTransformParentChanged()
22852285 return ;
22862286 }
22872287
2288- if ( ! NetworkManager . IsListening )
2288+ if ( ! IsSpawned || ! NetworkManager . IsListening )
22892289 {
2290+ if ( NetworkManager . ShutdownInProgress )
2291+ {
2292+ return ;
2293+ }
22902294 // DANGO-TODO: Review as to whether we want to provide a better way to handle changing parenting of objects when the
22912295 // object is not spawned. Really, we shouldn't care about these types of changes.
22922296 if ( NetworkManager . DistributedAuthorityMode && m_CachedParent != null && transform . parent == null )
@@ -2302,7 +2306,7 @@ private void OnTransformParentChanged()
23022306 // With distributed authority, we need to track "valid authoritative" parenting changes.
23032307 // So, either the authority or AuthorityAppliedParenting is considered a "valid parenting change".
23042308 isAuthority = HasAuthority || AuthorityAppliedParenting || ( AllowOwnerToParent && IsOwner ) ;
2305- var distributedAuthority = NetworkManager . DistributedAuthorityMode ;
2309+ var distributedAuthority = NetworkManagerOwner . DistributedAuthorityMode ;
23062310
23072311 // If we do not have authority and we are spawned
23082312 if ( ! isAuthority && IsSpawned )
@@ -2373,7 +2377,7 @@ private void OnTransformParentChanged()
23732377 var message = new ParentSyncMessage
23742378 {
23752379 NetworkObjectId = NetworkObjectId ,
2376- IsLatestParentSet = m_LatestParent is not null ,
2380+ IsLatestParentSet = m_LatestParent is not null && m_LatestParent . HasValue ,
23772381 LatestParent = m_LatestParent ,
23782382 RemoveParent = removeParent ,
23792383 AuthorityApplied = authorityApplied ,
@@ -3415,7 +3419,7 @@ private void CurrentlyActiveSceneChanged(Scene current, Scene next)
34153419 {
34163420 // Early exit if the NetworkManager is shutting down, the NetworkObject
34173421 // is not spawned, or an in-scene placed NetworkObject
3418- if ( NetworkManager . ShutdownInProgress || ! IsSpawned || IsSceneObject != false )
3422+ if ( ! IsSpawned || IsSceneObject != false || NetworkManager . ShutdownInProgress )
34193423 {
34203424 return ;
34213425 }
@@ -3425,7 +3429,7 @@ private void CurrentlyActiveSceneChanged(Scene current, Scene next)
34253429 {
34263430 // Only dynamically spawned NetworkObjects that are not already in the newly assigned active scene will migrate
34273431 // and update their scene handles
3428- if ( IsSceneObject . HasValue && ! IsSceneObject . Value && m_SceneOrigin != next && m_CachedParent == null )
3432+ if ( IsSceneObject . HasValue && ! IsSceneObject . Value && gameObject . scene != next && gameObject . transform . parent == null )
34293433 {
34303434 SceneManager . MoveGameObjectToScene ( gameObject , next ) ;
34313435 SceneChangedUpdate ( next ) ;
@@ -3517,8 +3521,8 @@ internal bool UpdateForSceneChanges()
35173521 // Early exit if SceneMigrationSynchronization is disabled,
35183522 // the NetworkManager is shutting down, the NetworkObject is not spawned, it is an in-scene placed
35193523 // NetworkObject, or the GameObject's current scene handle is the same as the SceneOriginHandle
3520- if ( ! SceneMigrationSynchronization || ! IsSpawned || NetworkManager . ShutdownInProgress ||
3521- ! NetworkManager . NetworkConfig . EnableSceneManagement || IsSceneObject != false || ! gameObject )
3524+ if ( ! SceneMigrationSynchronization || ! IsSpawned || NetworkManagerOwner . ShutdownInProgress ||
3525+ ! NetworkManagerOwner . NetworkConfig . EnableSceneManagement || IsSceneObject != false || ! gameObject )
35223526 {
35233527 // Stop checking for a scene migration
35243528 return false ;
0 commit comments