Search Unity

  1. Unity 2020.2 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Export FBX at runtime using Autodesk.Fbx?

Discussion in 'Import Formats & External Tools' started by Zipp, Jul 18, 2019.

  1. Zipp

    Zipp

    Joined:
    Dec 27, 2012
    Posts:
    13
    Hello,

    I want to export my GameObjects at runtime and save it as one FBX on the file system. I am Using Unity 2018.3 HDRP.

    I achieved to export it using the FBX Exporter preview package in the Unity Editor. However, it must also work in a Windows Standalone Build. In the documentation of the package I found following info using the Autodesk SDK to export a model also at runtime.

    Code (CSharp):
    1.  
    2. using Autodesk.Fbx;
    3. using UnityEngine;
    4. using UnityEditor;
    5.  
    6. protected void ExportScene (string fileName)
    7. {
    8.     using(FbxManager fbxManager = FbxManager.Create ()){
    9.         // configure IO settings.
    10.         fbxManager.SetIOSettings (FbxIOSettings.Create (fbxManager, Globals.IOSROOT));
    11.  
    12.         // Export the scene
    13.         using (FbxExporter exporter = FbxExporter.Create (fbxManager, "myExporter")) {
    14.  
    15.             // Initialize the exporter.
    16.             bool status = exporter.Initialize (fileName, -1, fbxManager.GetIOSettings ());
    17.  
    18.             // Create a new scene to export
    19.             FbxScene scene = FbxScene.Create (fbxManager, "myScene");
    20.  
    21.             // Export the scene to the file.
    22.             exporter.Export (scene);
    23.         }
    24.     }
    25. }
    26.  

    However, I do not understand how I can specify the GameObject that has to be exported. Is this even possible in this way or do I understand it wrong?

    Furthermore, when exporting the FBX file in Untiy HDRP, the textures in the materials are lost. Do I have to export all materials separately and then assign it again?

    Thank you for your help!
     
  2. chanig16

    chanig16

    Joined:
    Jul 4, 2019
    Posts:
    1
    Did you find a solution to this?
     
  3. Drallig

    Drallig

    Joined:
    Oct 28, 2015
    Posts:
    2
  4. GeorgeIngDCC

    GeorgeIngDCC

    Unity Technologies

    Joined:
    Jan 14, 2020
    Posts:
    22
    Hey, we don't officially support an Importer / Exporter that executes at runtime (The FBX Exporter package is Editor only). You'd have to write your own which hooks into the FBX SDK bindings.

    From looking on GitHub, it seems this is what a few people have done.
    For example: https://github.com/KellanHiggins/UnityFBXExporter
     
unityunity