Skip to content

Commit 84a5dd9

Browse files
update & style
Adding change log entry. Fixing some typos.
1 parent 842b67b commit 84a5dd9

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
2626

2727
### Fixed
2828

29+
- Fixed issue where either an `AttachableBehaviour` or an `AttachableNode` can throw an exception if they are attached during a scene unload where one of the two persists the scene unload event and the other does not. (#3931)
2930
- Fixed issue where attempts to use `NetworkLog` when there is no `NetworkManager` instance would result in an exception. (#3917)
3031

3132
### Security

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ protected override void OnNetworkPreSpawn(ref NetworkManager networkManager)
245245
IsDestroying = false;
246246
// When attached to something else, the attachable needs to know if the
247247
// default parent has been destroyed in order to not attempt to re-parent
248-
// when detached (especially if it is being detatched because it should be destroyed).
248+
// when detached (especially if it is being detached because it should be destroyed).
249249
NetworkObject.OnDestroying += OnDefaultParentDestroying;
250250

251251
base.OnNetworkPreSpawn(ref networkManager);
@@ -260,9 +260,13 @@ private void OnDefaultParentDestroying()
260260
return;
261261
}
262262
IsDestroying = true;
263-
// Just destroy the GameObject for this attachable since
264-
// the associated NetworkObject is being destroyed.
265-
Destroy(gameObject);
263+
// If not completely detached, then destroy the GameObject for
264+
// this attachable since the associated NetworkObject is being
265+
// destroyed.
266+
if (m_AttachState != AttachState.Detached)
267+
{
268+
Destroy(gameObject);
269+
}
266270
}
267271

268272
internal override void InternalOnDestroy()
@@ -319,7 +323,7 @@ public override void OnNetworkPreDespawn()
319323
}
320324

321325
/// <summary>
322-
/// This will apply the final attach or detatch state based on the current value of <see cref="m_AttachedNodeReference"/>.
326+
/// This will apply the final attach or detach state based on the current value of <see cref="m_AttachedNodeReference"/>.
323327
/// </summary>
324328
[MethodImpl(MethodImplOptions.AggressiveInlining)]
325329
private void UpdateAttachedState()

0 commit comments

Comments
 (0)