Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Can I set HasTransformHierarchy to false so that it uses the bones from an Avatar?

Discussion in 'Animation' started by burningmime, Mar 19, 2021.

  1. burningmime

    burningmime

    Joined:
    Jan 25, 2014
    Posts:
    845
    If I drag a model (with optimize game objects on) into a scene, the mesh will be visible. However, if I create an Animator, then a SkinnedMeshRenderer in a child component, and set all the same properties as the model prefab, it won't be visible. Inspecting the scene YAML, the only difference between the states of these is "m_HasTransformHierarchy: 0" in the model, and "m_HasTransformHierarchy: 1" in my generated case.

    Is there a way to set this property to false, so it will use the optimized hierarchy inside the avatar?
     
  2. geniusz

    geniusz

    Joined:
    Nov 21, 2014
    Posts:
    38
    I went to the same problem, unfortunately today hasTransformHierarchy is still readonly, since there's no answer yet, I'd like to necro this question and share my solution.

    Code (CSharp):
    1. using(var so = new SerializedObject(animator))
    2. {
    3.     so.FindProperty("m_HasTransformHierarchy").boolValue = false;
    4.     so.ApplyModifiedProperties();
    5. }