JetBrains / JetBrains/resharper-unity

Warn against using Mesh.vertices/Mesh.colors/... (causes GC allocation)

Open
#1,216 0 comments 3 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
1.2k
Forks
142
PR merge metrics
No merged PRs in 30d

Description

Unity has a few properties to access mesh data, such as [Mesh.vertices](https://docs.unity3d.com/ScriptReference/Mesh-vertices.html). Little did I know I shot myself in the foot with these calls as they actually create garbage every time. Instead it is advisable for the user to allocate a list and re-use it with [Mesh.GetVertices](https://docs.unity3d.com/ScriptReference/Mesh.GetVertices.html) and [Mesh.SetVertices](https://docs.unity3d.com/ScriptReference/Mesh.SetVertices.html). The same is true with several other properties such as `colors`, `normals`, etc. which have `GetX`/`SetX` counterparts.

Contributor guide

Open the contributing guide

Research direction

No repository files or tests are named. Start by reviewing the Unity Mesh.vertices, Mesh.colors, Mesh.normals, and related GetX/SetX APIs linked in the issue, then locate the project entry point for Unity API inspections. Done means the relevant property accesses are warned about and the reusable-list alternatives are communicated clearly.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, unity
Domain
performance, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.