Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2368,11 +2368,22 @@ internal bool InternalTrySetParent(NetworkObject parent, bool worldPositionStays
private void OnTransformParentChanged()
{
var networkManager = NetworkManager;
if (!AutoObjectParentSync || (networkManager != null && networkManager.ShutdownInProgress))
if (networkManager != null && networkManager.ShutdownInProgress)
{
return;
}

if (!AutoObjectParentSync)
{
// If this setting is off, we shouldn't be tracking parenting changes
// Ensure any tracking we do have is cleared.
if (m_CachedParent != null)
{
SetCachedParent(null);
}
return;
}

if (transform.parent == m_CachedParent)
{
return;
Expand All @@ -2388,7 +2399,6 @@ private void OnTransformParentChanged()

if (!IsSpawned)
{
AuthorityAppliedParenting = false;
// and we are removing the parent, then go ahead and allow parenting to occur
if (transform.parent == null)
{
Expand All @@ -2398,6 +2408,7 @@ private void OnTransformParentChanged()
}
else
{
AuthorityAppliedParenting = false;
transform.parent = m_CachedParent;
if (networkManager.LogLevel <= LogLevel.Error)
{
Expand Down