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

Using ModelImporter to set "Root Node" from script

Discussion in 'Editor & General Support' started by Avalix, Jul 15, 2014.

  1. Avalix

    Avalix

    Joined:
    Dec 10, 2012
    Posts:
    15
    Hey all,

    I am trying to automate a few steps of our fbx import process. I would like to be able to set up the Rig settings from script using a AssetPostprocessor and ModelImporter but i've hit a snag.

    I can set the Animation type to "Generic", but does anyone know a way I can automatically set the "Root Node" setting? I can't seem to find anything about it in the docs/forums. Is it simply not exposed?

    Cheers,
    Avalix
     
  2. a_p_u_r_o

    a_p_u_r_o

    Joined:
    May 27, 2015
    Posts:
    20
    Code (CSharp):
    1. ModelImporter importer = AssetImporter.GetAtPath("Asset/test.fbx") as ModelImporter;
    2. SerializedObject so = new SerializedObject(importer);
    3. so.FindProperty("m_HumanDescription.m_RootMotionBoneName").stringValue = "AlternateRootNode";
    4. so.ApplyModifiedProperties();
    5. importer.SaveAndReimport();
    Hint for this was found in source code available in UnityCsReference.
    AssetPipelineEditor/ImportSettings/ModelImporterRigEditor.cs