Search Unity

Runtime FBX Export using Autodesk sdk?

Discussion in 'Scripting' started by Zipp, Jul 17, 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. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,674
    You might want to repost over in the "External Tools" board because the answer to this is going to be highly dependent on details of this SDK.
     
  3. Zipp

    Zipp

    Joined:
    Dec 27, 2012
    Posts:
    13
    Thank you, I reposted it also in the second thread.