Animating "cloned" bones

I have a skinned mesh I generated from a bunch of other skinned meshes. It has weights, bind poses and everything.

But it still uses the skeleton from the one of the original meshes. How can I make it’s own skeleton?

I can do newBoneParent = Instantiate(originalBoneParent) to clone the original bones, and I can assign to SkinnedMeshRenderer.bones an array of the new bones.

But the new bones won’t move. I suppose they’re handled by the Animation class? But I can’t find any way to assign bones to that class. How does Unity know which bones(transforms) to animate?

The Mesh class contains an array called boneWeights which contains a BoneWeight object for each vertex. The BoneWeight contains the index and weight of each bone that affects the vertex. You can get the mesh using the SkinnedMeshRenderer’s sharedMesh property.

A word of warning here, though - other properties with the name sharedXXX in Unity modify the original source asset when you change them (see this doc page for details). The docs don’t explicitly mention that SkinnedMeshRenderer.sharedMesh has this effect, but, you know, be careful!