Skip to content

Avoid using allocating versions of Physics Raycast functions

Vladimir edited this page Dec 18, 2018 · 4 revisions

SphereCast, RaycastAll, CapsuleCast, BoxCast, OverlapBox, OverlapCapsule, OverlapSphere alllocates managed memory every call and this effects performance. Allocate your own results array for saving performance and using the appropriate NonAlloc API. These APIs allows for result array reuse to prevent frequent allocations.

This inspection will highlight using alloc versions of physics API and provide quick fix (Alt+Enter) which will transform using to NonAlloc API and create buffer for result.

History:

  • This inspection was first added in Rider/ReSharper 2018.3
Clone this wiki locally