Skip to content

Commit dd7d4c9

Browse files
Update AttachableBehaviour.cs
Applying modifications suggested by Emma.
1 parent 39c999c commit dd7d4c9

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

com.unity.netcode.gameobjects/Runtime/Components/Helpers/AttachableBehaviour.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -499,18 +499,16 @@ public void Detach()
499499
if (!m_AttachableNode)
500500
{
501501
NetworkLog.LogError($"[{name}][Detach] Invalid state detected! {name}'s state is still {m_AttachState} but has no {nameof(AttachableNode)} assigned!");
502+
// Developer only notification for the most likely scenario where this method is invoked but the instance is not attached to anything.
503+
if (NetworkManager && NetworkManager.LogLevel <= LogLevel.Developer)
504+
{
505+
NetworkLog.LogWarning($"[{name}][Detach] Cannot detach! {name} is not attached to anything!");
506+
}
502507
}
503-
504-
// Developer only notification for the most likely scenario where this method is invoked but the instance is not attached to anything.
505-
if (!m_AttachableNode && NetworkManager && NetworkManager.LogLevel <= LogLevel.Developer)
506-
{
507-
NetworkLog.LogWarning($"[{name}][Detach] Cannot detach! {name} is not attached to anything!");
508-
}
509-
510-
// If we have the attachable node set and we are not in the middle of detaching, then log an error and note
511-
// this could potentially occur if inoked more than once for the same instance in the same frame.
512-
if (m_AttachableNode)
508+
else
513509
{
510+
// If we have the attachable node set and we are not in the middle of detaching, then log an error and note
511+
// this could potentially occur if inoked more than once for the same instance in the same frame.
514512
NetworkLog.LogError($"[{name}][Detach] Invalid state detected! {name} is still referencing {nameof(AttachableNode)} {m_AttachableNode.name}! Could {nameof(Detach)} be getting invoked more than once for the same instance?");
515513
}
516514
return;

0 commit comments

Comments
 (0)