Search Unity

Bug Unloading additive scene causes Native script crash in network list.

Discussion in 'Netcode for GameObjects' started by hoesterey, Apr 13, 2022.

  1. hoesterey

    hoesterey

    Joined:
    Mar 19, 2010
    Posts:
    659
    Code (CSharp):
    1. ObjectDisposedException: The Unity.Collections.NativeList`1[Unity.Netcode.NetworkBehaviourReference] has been deallocated, it is not allowed to access it
    2. Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckDeallocateAndThrow (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle handle) (at <ad50157ee00e45cdb3c8bd67012f8804>:0)
    3. Unity.Collections.LowLevel.Unsafe.DisposeSentinel.Dispose (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle& safety, Unity.Collections.LowLevel.Unsafe.DisposeSentinel& sentinel) (at <ad50157ee00e45cdb3c8bd67012f8804>:0)
    4. Unity.Collections.NativeList`1[T].Dispose () (at Library/PackageCache/com.unity.collections@1.1.0/Unity.Collections/NativeList.cs:532)
    5. Unity.Netcode.NetworkList`1[T].Dispose () (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0-pre.5/Runtime/NetworkVariable/Collections/NetworkList.cs:474)
    6. Unity.Netcode.NetworkBehaviour.OnDestroy () (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0-pre.5/Runtime/Core/NetworkBehaviour.cs:678)
    7. Game.Encounter.OnDestroy () (at Assets/Game/Scripts/Shared/Gameplay/Encounter/Encounter.cs:131)
    8. Game.CombatEncounter.OnDestroy () (at Assets/Game/Scripts/Shared/Gameplay/Encounter/CombatEncounter.cs:343)
    9.  
    The combatEncounter is a network object that exists within a scene. The scene is additivaly loaded and then later unloaded. When unloaded it causes this script crash.