So I have my base model/rig, and from that model I created prefabs which are basically copies of the original with different clothes toggled on or off.
I just added a new hair-mesh to the base model/rig. I want to add this new hair mesh to some of my prefabs, so what I did was
drag a whole new copy of the original rig, LowPolyModel, into the prefab, Cashier
right clicked and unpacked the new copy of LowPolyModel completely
pulled over the two new hair meshes from LowPolyModel onto Cashier, updated the root bone to use the root bone of Cashier and then deleted copied instance of LowPolyModel from the prefab
After step three, the hair meshes disappear. The game objects are there, but the meshes are invisible. I suspect that these game objects or the skinned mesh renderer is still referencing something from the now deleted LowPolyModel instance.
It also seems like I can’t add the mesh manually with a new gameobject/skinned mesh renderer. There’s another step that I’m either missing or isn’t in the inspector.
Does anyone know how I can go about doing this? I rather not have to re-do my entire prefab every time I add new hair or clothes.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteInEditMode]
public class ReassignBoneWeigthsToNewMesh : MonoBehaviour
{
public Transform newArmature;
public string rootBoneName = "Hips";
public bool PressToReassign;
void Update()
{
if (PressToReassign)
Reassign();
PressToReassign = false;
}
// [ContextMenu("Reassign Bones")]
public void Reassign()
{
if (newArmature == null) {
Debug.Log("No new armature assigned");
return;
}
if (newArmature.Find(rootBoneName) == null) {
Debug.Log("Root bone not found");
return;
}
Debug.Log("Reassingning bones");
SkinnedMeshRenderer rend = gameObject.GetComponent<SkinnedMeshRenderer>();
Transform[] bones = rend.bones;
rend.rootBone = newArmature.Find(rootBoneName);
Transform[] children = newArmature.GetComponentsInChildren<Transform>();
for (int i = 0; i < bones.Length; i++)
for (int a = 0; a < children.Length; a++)
if (bones*.name == children[a].name) {*