How to re-apply a mesh to an armature?

Thanks! That’s work for me. I tried to solve it in 2024 and just adding some additional description for @JLJac solution:

Importantly, you should run the script before you remove actual object armature

1. Create the script in your Unity project and Attach it to object with SkinnedMeshRenderer what you want to re-apply:

using UnityEngine;

[ExecuteInEditMode]
public class ReassignBoneWeightsToNewMesh : MonoBehaviour
{
   [SerializeField] public Transform _newArmature;
   [SerializeField] public string _rootBoneName = "Hips";
   public bool _reassign;

   private void Update()
   {
       if (_reassign)
           Reassign();
       _reassign = false;
   }

   private void Reassign()
   {
       if (!_newArmature)
       {
           Debug.Log("No new armature assigned");
           return;
       }

       var rootBone = FindRecursive(_newArmature, _rootBoneName);
       if (!rootBone)
       {
           Debug.Log("Root bone not found");
           return;
       }

       var meshRenderer = gameObject.GetComponent<SkinnedMeshRenderer>();
       if (!meshRenderer)
       {
           Debug.Log("SkinnedMeshRenderer not found");
           return;
       }

       // Reassign root bone
       meshRenderer.rootBone = rootBone;

       var newArmatureBones = _newArmature.GetComponentsInChildren<Transform>();
       var meshRendererBones = meshRenderer.bones;

       // Reassign bones
       for (var i = 0; i < meshRendererBones.Length; i++)
       {
           foreach (var bone in newArmatureBones)
           {
               if (meshRendererBones[i].name != bone.name) continue;
               meshRendererBones[i] = bone;
               break;
           }
       }

       meshRenderer.bones = meshRendererBones;
       Debug.Log("Bones reassigned successfully.");
   }
   
   private static Transform FindRecursive(Transform parent, string targetName)
   {
       if (parent.name == targetName)
           return parent;

       foreach (Transform child in parent)
       {
           var result = FindRecursive(child, targetName);
           if (result) return result;
       }

       return null;
   }
}

2. Provide parameters for this script in the Inspector. It will be your new Armature game object and the name of bone what currently selected like a Root Bone in your SkinnedMeshRenderer.

3. Click to Reassign checkbox in the Inspector and check the result. If reassigning was successful, you can Remove this script component from game object.