• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by jfonz001 · Aug 02, 2021 at 01:46 PM · meshblenderskinnedmeshrendererarmature

Trying to add a mesh parented to an armature to another instance of the same armature

So I have my base model/rig, and from that model I created prefabs w$$anonymous$$ch 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 t$$anonymous$$s new hair mesh to some of my prefabs, so what I did was

1) drag a whole new copy of the original rig, LowPolyModel, into the prefab, Cas$$anonymous$$er

2) right clicked and unpacked the new copy of LowPolyModel completely

3) pulled over the two new hair meshes from LowPolyModel onto Cas$$anonymous$$er, updated the root bone to use the root bone of Cas$$anonymous$$er 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 somet$$anonymous$$ng 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 t$$anonymous$$s? I rather not have to re-do my entire prefab every time I add new hair or clothes.

Thank you.

alt text

meshissue.png (307.6 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by jfonz001 · Aug 02, 2021 at 08:20 PM

Got it:

https://answers.unity.com/questions/1442963/how-to-re-apply-a-mesh-to-an-armature.html

  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[] c$$anonymous$$ldren = newArmature.GetComponentsInC$$anonymous$$ldren<Transform>();
  
          for (int i = 0; i < bones.Length; i++)
              for (int a = 0; a < c$$anonymous$$ldren.Length; a++)
                  if (bones[i].name == c$$anonymous$$ldren[a].name) {
                      bones[i] = c$$anonymous$$ldren[a];
                      break;
                  }
  
          rend.bones = bones;
      }
  
  }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

152 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Importing .blend file - Missing Animation 1 Answer

Mesh is flipped thanks to bone but armature is working 0 Answers

Importing from my blender to unity with armatures causes my mesh to be see through 0 Answers

My animation will not play after I apply armature in Blender. 1 Answer

Importing a mesh with multiple armatures from blender 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges