Search Unity

Possible to read extra attributes in an FBX after importing?

Discussion in 'Asset Importing & Exporting' started by tcn5150, Feb 19, 2022.

  1. tcn5150

    tcn5150

    Joined:
    Dec 1, 2012
    Posts:
    26
    I'm trying to use extra attributes (Maya) in Unity to inform some automated rig building with imported .fbx models. Ideally an editor script would be able to access these attributes on demand.

    I know that upon import/reimport I can use AssetPostprocessor.OnPostprocessGameObjectWithUserProperties() to read the attributes. But having to reimport a model to gain one-time access to these attributes' values, then storing them elsewhere, seems roundabout. As would invoking the asset reimport upon executing any automated rig building/update. Am I missing a simpler way to handle this?

    Thanks!
     
  2. bastien_humeau

    bastien_humeau

    Unity Technologies

    Joined:
    Jun 14, 2017
    Posts:
    191
    Hi @tcn5150,

    Unfortunately, that is not possible without an AssetPostprocessor as these settings are discarded if not used during the import.
    I don't think there is a better way than handling everything from inside of the AssetPostprocessors at the moment and I agree it feels cumbersome to have everything re-importing when you want to change only this automated process...

    One way I know some have done it in the past is to create a plugin in Maya to extract the values you want into an xml or json file while you create the fbx file and bring it into Unity alongside your fbx file. Then you can write a ScriptedImporter that would read this extra file and generate your rig based on the imported model and the content of this file.
    This lets you separate all of the rig building/update from the ModelImport in Unity, but it adds a burden of generating the correct data first from outside of Unity...