Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Extract custom properties from fbx - I'm almost there !

Discussion in 'Asset Importing & Exporting' started by Thibault_potier, Jul 29, 2021.

  1. Thibault_potier

    Thibault_potier

    Joined:
    May 4, 2021
    Posts:
    46
    Hi

    I want to be able to read custom properties that 3d artist have put on fbx nodes. My purpose is to implement custom behaviour by reading those values. So far I'm able to access them when unity import the .fbx file by using OnPostprocessGameObjectWithUserProperties

    Code (CSharp):
    1. void OnPostprocessGameObjectWithUserProperties(
    2.         GameObject go,
    3.         string[] propNames,
    4.         System.Object[] values)
    5.     {
    6.  
    7.         Debug.Log(go.name +" -----------------------------------------------");
    8.  
    9.         for (int i = 0; i < propNames.Length; i++)
    10.         {
    11.             string propName = propNames[i];
    12.             System.Object value = (System.Object)values[i];
    13.  
    14.             Debug.Log("Propname: " + propName + " value: " + values[i]);
    15.         }
    16.     }
    But it seems that I have a problem when reading some of the values :/

    properties shown in blender :



    properties retrieved with the above code :



    As you can see, property "type" has now value "0" instead of "rotation"; and property "axis" is now "2" instead of "X".

    The weird thing is that property "nameAtt" has kept its string value "wheel", so I really don't know what to conclude here.

    Does anyone have explanations, tips, or solutions to be able to retrieve properly those custom attributes? :p
     
  2. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,669
    Do "type" and "axis" come from drop-down menus? Maybe Blender is exporting the index, rather than the text value?