Search Unity

Autodesk.fbx build errors for Windows

Discussion in 'Windows' started by Zipp, Jul 26, 2019.

  1. Zipp

    Zipp

    Joined:
    Dec 27, 2012
    Posts:
    13
    Hello,

    the FbxExporter package from Unity gives the possibility to export GameObjects as FBX files. According to the documentation this is also possible at runtime when implementing the exporter completely using Autodesk.Fbx (the autodesk fbx sdk).

    I achieved now to successfully export the models in the editor. However, when I try to build the application as a Windows Standalone x64, I always get the following error:

    Assets\StandardAssets\FbxExport.cs(5,7): error CS0246: The type or namespace name 'Autodesk' could not be found (are you missing a using directive or an assembly reference?)

    According to the following link it also should work in the build as well:
    https://docs.unity3d.com/Packages/com.unity.formats.fbx@2.0/manual/devguide.html

    Can anybody help me? I already looked into some files of the Autodesk package and I found the NativeMethods.cs script where one can specify the DllImportName as following:

    Code (CSharp):
    1. #if UNITY_EDITOR_OSX
    2.   const string DllImportName = "Packages/com.autodesk.fbx/Runtime/Plugins/x86_64/UnityFbxSdkNative.bundle/Contents/MacOS/UnityFbxSdkNative";
    3. #elif UNITY_EDITOR_LINUX
    4.   const string DllImportName = "Packages/com.autodesk.fbx/Runtime/Plugins/x86_64/UnityFbxSdkNative.so";
    5. #elif UNITY_EDITOR_WIN
    6.   const string DllImportName = "Assets/Autodesk/Plugins/x86_64/UnityFbxSdkNative.dll";
    7. #elif COM_UNITY_FORMATS_FBX_AS_ASSET || UNITY_STANDALONE
    8.   const string DllImportName = "UnityFbxSdkNative";
    9. #else
    10. #error "FbxSdk: C# bindings for this platform haven't been implemented yet, sorry."
    11.         const string DllImportName = "UnityFbxSdkNative";
    12. #endif
    13.  
    14.  
    One can see, that also the UNITY_STANDALONE is supported. I have tried to set a correct path to the dll here, but this did not change anything.

    Thanks for any help!
     
  2. vkovec

    vkovec

    Unity Developer - FBX Exporter

    Joined:
    Aug 9, 2017
    Posts:
    175
    Hi @Zipp ,

    You shouldn't need to change the path in NativeMethods.cs.

    This looks like an issue with the FBX SDK assembly file being set to editor only. Until we fix this issue, here is a workaround:

    1. Locate the Autodesk.Fbx.asmdef file under packages
    upload_2019-7-26_14-33-5.png

    2. Right click and select "Show in Explorer" option
    upload_2019-7-26_14-34-8.png

    3. In the explorer right click on the Autodesk.Fbx.asmdef file and select "Properties"
    4. In the properties make sure "Read Only" is unchecked
    upload_2019-7-26_14-35-16.png

    5. Open the file in a text editor and under "includePlatforms" remove the word "Editor" and save

    Code (csharp):
    1.  
    2. {
    3.     "includePlatforms": [
    4.         "Editor"
    5.     ],
    6. }
    7.  
    Now if you go back to Unity you should be able to build the project.

    Let me know if this doesn't fix the issue.

    Best,
    Viktoria
     
  3. AlbyDj90

    AlbyDj90

    Joined:
    Feb 7, 2015
    Posts:
    33
    Hi,
    i've got a similar issue that i managed to resolve with your advice but i've got another error when i try to build:
    error CS0234: The type or namespace name 'Formats' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?).
    I tried to apply the same procedure but Unity.Formats.Fbx.Runtime.Asmdef is different:

    Code (csharp):
    1.  
    2. {
    3.     "name": "Unity.Formats.Fbx.Runtime",
    4.     "references": [],
    5.     "optionalUnityReferences": [],
    6.     "includePlatforms": [],
    7.     "excludePlatforms": [],
    8.     "allowUnsafeCode": false,
    9.     "overrideReferences": false,
    10.     "precompiledReferences": [],
    11.     "autoReferenced": true,
    12.     "defineConstraints": [],
    13.     "versionDefines": []
    14. }
    15.  
    How can i resolve this?
    Thanks

    EDIT: I see the problem is that i cant use something in the UnityEditor namespace...so the example script for exporting FBX models in the dev guide is no use for me.
    There is a way for export some objects in a FBX file like that example but in runtime? I cant find anything...
     
    Last edited: Oct 18, 2019
  4. Dist0

    Dist0

    Joined:
    Oct 28, 2017
    Posts:
    1
    Hi,
    This doesn't seems to be a valid fix. Dll was not found when using all 3.0 packages. I've to revert back to earlier 2.0 version in order to work without weird package modification. (by Scripting and on editor, it's the same)
    Also why the ModelExporter class from the Api implement IDispose while the class only have a static method Model.Export() and don't have any instance stuffs? => https://docs.unity3d.com/Packages/c...ditor.Formats.Fbx.Exporter.ModelExporter.html
    The documentation lack? Or that's this kind of thing who make that's stay on preview... I've maybe missed something, but why do you publish a preview package when her main feature doesn't work on the main target platform ?
    Sorry, but some time lost for nothing, really.
     
  5. vkovec

    vkovec

    Unity Developer - FBX Exporter

    Joined:
    Aug 9, 2017
    Posts:
    175
    Hi @AlbyDj90,

    Unfortunately the FBX exporter does not currently support export at runtime. However, you could use the FBX SDK C# bindings (com.autodesk.fbx package) to write your own runtime exporter. There is a simple example of an exporter in the developer guide: https://docs.unity3d.com/Packages/com.unity.formats.fbx@3.0/manual/devguide.html.
    You can also reuse several of the functions from the FBX exporter (Packages/com.unity.formats.fbx/Editor/FbxExporter.cs file) for exporting different types of objects/components.

    Hope this helps,
    Viktoria
     
  6. vkovec

    vkovec

    Unity Developer - FBX Exporter

    Joined:
    Aug 9, 2017
    Posts:
    175
    Hi @Dist0,

    Sorry to hear this is still an issue with the 3.0 packages, we had pushed a fix in version 3.0.0. Which version of Unity were you using? Also which platform are you targeting?

    As for the API documentation, there are additional functions in the ModelExporter class, however they are not currently documented/exposed for use. You can check out the full implementation either in the Packages/com.unity.formats.fbx/Editor/FbxExporter.cs file in your project, or on the GitHub: https://github.com/Unity-Technologi...w/com.unity.formats.fbx/Editor/FbxExporter.cs.

    Best,
    Viktoria
     
  7. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    6,360
    I had the same issue with package 3.0.x and latest LTS. I had to revert back to 2.0.x versions of the package.
     
unityunity