TrailRenderer GetPositions NativeArray

I noticed that TrailRenderer has a GetPositions/GetVisiblePositions overload that has an out parameter with a native array of the positions. In practice, it doesn’t seem to actually work as an out parameter - an initialized NativeArray is required without the ‘out’ parameter or the compiler throws a “cannot resolve method” error.

How exactly is this supposed to be used? Is a NativeArray with a size of 0 the best choice? What Allocator type should be used or will it be overwritten by the GetPositions method anyway? Is this an undocumented change, or a mistake?

The documentation page is treating OutAttribute as simply the language keyword out. It also doesn’t particularly make sense to have OutAttribute on the NativeArray/NativeSlice overloads.

Just pass in a pre-allocated buffer with whatever allocator you deem appropriate for your usage. As the page says, the return value will be the number of elements actually stored. You can use positionCount for the base element allocation count.

ok, gotcha. seems like a similar pattern to the physics non alloc methods. i’ll give it a go. thanks @Spy-Master !