I tried to modify vertices and other stuff like mesh.vertices[i], but I forgot that I need to create a buffer Vector3[] verts, copy vertices there and then do mesh.vertices = verts;
Ok, I am not sure what I did wrong in the previous piece of code - but I’ve just completely solved my problem with a “combine one mesh into one mesh”-workaround like this:
combineInstances = new List<CombineInstance>();
for (int sub = 0; sub < smr.sharedMesh.subMeshCount; sub++)
{
CombineInstance ci = new CombineInstance();
ci.mesh = smr.sharedMesh;
ci.subMeshIndex = sub;
combineInstances.Add(ci);
}
smr.sharedMesh = new Mesh();
smr.sharedMesh.CombineMeshes(combineInstances.ToArray(), true, false);
i save the verts, uvs, etc from the skinned mesh renderer’s shared mesh at Awake(). The on OnDisable(), I restore them to the original values. so far, its worked for me as I work within the editor. I’m sure once the game is done, it will be fine as well.
Thanks so much the_gnoblin for finding this workaround all those years ago. SkinnedMeshRenderer still does not expose the mesh property, only sharedMesh. Your code is still extremely useful.