NonAlloc in Unity is either deprecated or ineffective
Hi, just felt worth mentioning... I noticed Rider suggests "Use non-allocating method for ..." e.g. 'OverlapCircleNonAlloc'. But a Unity developer over at the Unity forums say they are deprecated or "tentatively deprecated".
His exact quote:
"Yeah, it's technically not deprecated because it would cause a lot of users to be frustrated but all 2D queries with "NonAlloc" suffix are tentatively deprecated. All 2D queries (without exception) have an overload that replaces these calls (that take an array) and also accept a list.
OverlapCircleNonAlloc -> OverlapCircle
RaycastNonAlloc -> Raycast
etc."
Please sign in to leave a comment.
Hello,
could you please share the code that produces this suggestion for you? Also, which version of Rider do you use?
Hello,
Has it appeared in code completion suggestions for you, or did you have an error or a warning produced by a usage of Physics2D.OverlapCircle()? Would it be possible for you to provide a screenshot?
Thank you in advance.
Unfortunately I can't provide a screenshot. I clicked something to make the suggestions disappear, and I can't find where to get them back for testing. However, this was the link from the suggestions: https://github.com/JetBrains/resharper-unity/wiki/Avoid-using-allocating-versions-of-Physics-Raycast-functions
I've tried to re-enable them in the Inspection Severity window, just for testing, but it doesn't seem to bring back the suggestions (see screen shot).
All I can say is sometimes when I typed "Physics2D.OverlapCircle" it suggested the "Physics2D.OverlapCircleNonAlloc", probably when dealing with arrays, but all "NonAlloc" suffixes seems to be tentatively deprecated according to Unity.
Hello,
Thank you for the details. As far as I understand from your description, you are referring to non-allocating methods popping up in completion suggestions. Unfortunately there's currently no way to exclude specific suffixes from completion suggestion, apologies about that. Feel free to submit a new feature request to our tracker.
Since these methods are not completely deprecated and are still present in the Unity API, they will be present in the completion suggestions.
Let me know if you have any other questions. Have a great day!