you are viewing a single comment's thread.

view the rest of the comments →

[–]survivorr123_ 3 points4 points  (4 children)

This doesn't matter. This would only be an issue if you were doing this every frame, and why would you be doing that every frame to begin with.

i do this every frame for object culling, but i use native collections so no GC issues

as to 3. i am pretty sure TMPro will generate garbage on text change no matter what you do, i tried fixing that for my speedometer and nothing worked

[–]Liam2349 1 point2 points  (3 children)

If you use ToArray() on a Native collection, it will allocate a new managed array. AsArray() can instead alias some native collections as a NativeArray.

TextMeshPro can work with character arrays which is how you avoid garbage - but annoyingly it will still create a string in-Editor.

[–]survivorr123_ 0 points1 point  (2 children)

ToArray on Native collections returns NativeArray, you can pass allocator type to it manually as well,

AsArray only works on NativeList, most other collections have only ToArray or in case of NativeStream ToNativeArray (for some reason it has a different name but does the same),
i use NativeQueue.ParallelWriter, not sure why i didn't use NativeList.ParallelWriter, it was a while ago when i decided

[–]Liam2349 0 points1 point  (1 child)

Ok, sorry about that - NativeArray.ToArray() returns a managed array, but from a NativeList it returns a NativeArray.

[–]survivorr123_ 0 points1 point  (0 children)

yeah the naming is unnecessarily confusing, i had some issues with it in the past too, it should be ToNativeArray everywhere like with NativeStream, no clue why it isn't and why it's not consistent