Replace a Skinned Mesh in a character with a new Skinned Mesh

To help illustrate my problem, I have the following PDF that I created: 1

Basically, CharacterPrefab is based off of CharacterFBX and is what is in the scene of the game. ReplacementPrefab is based off of ReplacementFBX. I want to take MeshObj1 of the character, and replace it with the MeshObj of the replacement, as I do not need to duplicate the skeleton already on the character. I need to know the best way to do so.

I tried to use Resources.Load() to get a GameObject of the FBX with it's hierarchy, and then using Find() on it's transform to get just the mesh and then using it's gameObject property with Instantiate() to create a new copy. I then tried to set it's parent transform to the transform of the character, but that seemed to do nothing, the duplicate just floats where it was copied, and the copy does not get placed with the character even when I use transform.position and transform.rotation in the Instantiate() call.

I also tried earlier to not bother with trying to find the mesh's object and just set the parent transform of the base GameObject to the character's transform. This made it follow the character, but it was not placed correctly (just a little higher than it should've been) and ignored the skeleton when moving. Looking in the hierarchy during gameplay shows that the full object was placed on the character, which is why I think it's not following the character's bones.

If there is some other way I should be going about this, I would like to know. What I really need is an easy and/or sure-fire way to swap out a single mesh out of X number of meshes from a character. I can't place a list of GameObject transforms on a script as we have no idea how many replacement meshes we will eventually have.

So in the end, my question would be this: What is the best (and probably easiest) way to replace a single mesh in a character that has multiple meshes?

Well, one of the Ideas that I had, was to create added objects (clothing etc.,) and just add them to the character. That makes it to where one doesn’t need to swap out the mesh, if the main mesh is the basis of all the others.
Then, I changed out the material on the mesh… This seemed to work well for the primary material, but things start to go a bit hinky when doing secondary materials. My main character has two materials in its mesh, and I can change the primary just fine, add in any number of clothing/props/etc., but if I swap the secondary material out, it fails, and swaps the primary instead.
The last resort option that I have is to just swap the player out with another prefab, that has been set up with the secondary material preset, and just use the material swap and prop swap to do the rest. This might work well, for answering this question, as the prefabs can be instantiated in code, and as long as you find the player (usually named something like “Player(Clone)” if you’ve instantiated a prefab named Player at runtime).
those are the options & ideas that I came up with. Hope that it helps.

Try something like this:

Assuming your replacement mesh is in the Resources folder...


theMainMesh = GameObject.FindWithTag("sometag");

var Swapper : SkinnedMeshRenderer = theMainMesh.GetComponent(SkinnedMeshRenderer);

SwapMesh = Resources.Load("the_Replacement_Mesh_filename", Mesh);
Swapper.sharedMesh = SwapMesh;