- Home /
Efficient access to Mesh arrays
I am using SkinnedMeshRenderer.BakeMesh every frame and then retrieving the arrays of vertices, triangles, normals etc. for further processing.
The problem is that Unity's implementation of these property getters creates a new array every single call, rather than updating an existing one and returning it, and that leads to unnecessary object allocation and frequent GC spikes.
A few implementations that could have solved the problem, had they existed:
Mesh.GetVertex(int index), Mesh.GetTriangle(int index), etc. - direct access to an array member
Mesh.GetVertices(ref float[] outputArray), etc. - could perform an array copy instead of a new array allocation
Are there any actual ways to access this data without the GC overhead?
Answer by daterre · Jun 08, 2014 at 10:45 AM
As of June 2014, there is no way to do this as confirmed in this post on the Unity forums.
Your answer
Follow this Question
Related Questions
Native Mesh Access 1 Answer
Reasonable heap alloc. per second and total ? 0 Answers
Are big meshes all held in memory? 3 Answers
Optimize (Garbage Collection, Memory usage) 1 Answer
ManagedHeap.ReservedUnusedSize 0 Answers