marijnz / NativeQuadtree

A Quadtree Native Collection for Unity DOTS
MIT License
358 stars 30 forks source link

Newer version of Unity (2019 LTS) throws NativeArray not allocated exception when trying to draw tree #9

Open VergilUa opened 3 years ago

VergilUa commented 3 years ago

This happens because of NativeQuadTree.Draw tries to GetEnumerator from results, which does not exist. Can be simply fixed by checking if results list exist like so:

if (results.IsCreated) {
    foreach (var element in results) {
        texture[(int) ((element.pos.x + widthAdd) * widthMult)][(int) ((element.pos.y + heightAdd) * heightMult)]   = Color.green;
    }
}
marijnz commented 3 years ago

That makes sense. You could create a PR for this if you like.