#NativeArray NullReferenceException

1 messages · Page 1 of 1 (latest)

pine garnet
#

I'm getting a null ref here on line 371. GridPositions is a NativeList, and presumably the underlying list has been disposed or deleted or something. Is there any way to check this for safety or do I just have to trap the exception?

dim sand
#

So I assume that group is a class and is null

#

Although then it would null ref at the previous line since you are using group there too 🤔

#

What is the actual error you are getting?

pine garnet
#

NullReferenceException: Object reference not set to an instance of an object at AGSystemBase.GroupHasSpace (TerrainGroup group, ObjectiveData objective, Unity.Mathematics.int2 hoverPosition) [0x00011] in C:\dev\Tiles\TilesUnityProject\Assets\Game\Code\Scenario\Runtime\Systems\AGSystemBase.cs:371 at CleanupSystem.RemoveFinishedObjectives () [0x0005d] in C:\dev\Tiles\TilesUnityProject\Assets\Game\Code\Scenario\Runtime\Systems\CleanupSystem.cs:53 at CleanupSystem.UpdateInPhase () [0x00001] in C:\dev\Tiles\TilesUnityProject\Assets\Game\Code\Scenario\Runtime\Systems\CleanupSystem.cs:28 at AGPhasedSystem.OnUpdate () [0x00027] in C:\dev\Tiles\TilesUnityProject\Assets\Game\Code\Scenario\Runtime\Systems\AGPhasedSystem.cs:39 at Unity.Entities.SystemBase.Update () [0x00071] in .\Library\PackageCache\com.unity.entities@8b72e8a7d7d1\Unity.Entities\SystemBase.cs:420 at Unity.Entities.ComponentSystemGroup.UpdateAllSystems () [0x00174] in .\Library\PackageCache\com.unity.entities@8b72e8a7d7d1\Unity.Entities\ComponentSystemGroup.cs:734

#

Native collections are structs, but somewhere in there they have an unsafe pointer that presumably can be null.

#

group is also a struct, but I think it's getting set to default. Which seems to leave NativeList in a state where it will null ref if you ask for its length.

dim sand
#

I would just expect a different exception here, not a plain old null ref

ancient nexus
#

i think the IsCreated property might be what you need?

dim sand
#

I missed that part of the question from OP completely (got stuck on the null ref), yeah, that's what they need