#NativeArray NullReferenceException
1 messages · Page 1 of 1 (latest)
Native collections can't be "null" since they are structs, you'd be seeing a different error if the nativelist wasnt created yet or was already disposed.
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?
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.
Yep that is expected
I would just expect a different exception here, not a plain old null ref
i think the IsCreated property might be what you need?
I missed that part of the question from OP completely (got stuck on the null ref), yeah, that's what they need