Search Unity

ModelImporter.transformPaths broken in Unity 2018.3.3? Always returns empty list.

Discussion in 'Immediate Mode GUI (IMGUI)' started by jashan, Jan 31, 2019.

  1. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,085
    We're using a custom AssetPostprocessor to automate setting up ModelImporter.extraExposedTransformPaths. The way we do this is by iterating over ModelImporter.transformPaths, checking for names and then assigning the resulting list to ModelImporter.extraExposedTransformPaths.

    This worked flawlessly until Unity 2018.2.20f1. Now, after upgrading to Unity 2018.3.3, transformPaths always returns an empty list and our asset post processor breaks.

    The transforms are shown correctly in the inspector UI, with fancy checkbox-tree.

    I've tried several things to fix / work around this issue: Moved the code from OnPreprocessModel() to OnPostprocessModel(), set dragonImporter.optimizeGameObjects to false ... but so far, no matter what I do, transformPaths always is an empty list.

    Any ideas what is the issue with this, and how I can solve it?
     
  2. AaronZurawski

    AaronZurawski

    Joined:
    Feb 21, 2013
    Posts:
    4
    I'm also running into this issue, it seems that no matter what I do I always get back an empty transformPaths property.
     
  3. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,085
    It turns out they have changed this "by design" because transformPaths always returned the list from the previous import (I had filed this as (Case 1124508) Regression 2018.2 to 2018.3: ModelImporter.transformPaths is empty).

    It's a bit of a hassle to fix this, but here's some rough example code to get you started:

    Code (CSharp):
    1.     public void OnPostprocessMeshHierarchy(GameObject root) {
    2.         // only do this for the rig:
    3.         if (root.name.Equals("YourRigRootNodeName")) {
    4.             List<string> paths = new List<string>();
    5.             BuildTransformPaths(paths, root.transform);
    6.             string[] transformPaths = paths.ToArray();
    7.          
    8.             // AssignExposedTransformPaths can now be implemented
    9.             // like OnPreprocessModel used to be
    10.             //AssignExposedTransformPaths((ModelImporter)assetImporter, transformPaths);
    11.         }
    12.     }
    13.  
    14.     private void BuildTransformPaths(List<string> paths, Transform transform) {
    15.         List<string> currentPath = new List<string>();
    16.         Transform current = transform;
    17.         currentPath.Add(current.name);
    18.         while (current.parent != null) {
    19.             current = current.parent;
    20.             currentPath.Add(current.name);
    21.         }
    22.         currentPath.Reverse();
    23.         paths.Add(string.Join("/", currentPath.ToArray()));
    24.         foreach (Transform child in transform) {
    25.             BuildTransformPaths(paths, child);
    26.         }
    27.     }
    28.