usd-unity-sdk: UsdzExport doesn't work in Build when using IL2CPP, causes Exception (FTV-248)
When scripting backend is set to Mono, I can export USDZ fine from a Windows Desktop build (haven’t verified completeness yet, but I do get an USDZ file with geometry in it).
When the scripting backend is set to IL2CPP instead, calling ExportUsdz results in exceptions:
Registering plugins: D:/git/schreibkugel/development/Builds/usdzTest/WritingBall_Data/Plugins/share/
UnityEngine.Logger:LogFormat(LogType, String, Object[])
UnityEngine.Debug:LogFormat(String, Object[])
Unity.Formats.USD.InitUsd:Initialize()
Unity.Formats.USD.UsdzExporter:ExportUsdz(String, GameObject)
RuntimeExport:Update()
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 48)
NotSupportedException: To marshal a managed method, please add an attribute named 'MonoPInvokeCallback' to the method definition. The method we're attempting to marshal is: pxr.UsdCsPINVOKE+SWIGExceptionHelper::SetPendingApplicationException
at pxr.UsdCsPINVOKE+SWIGExceptionHelper..cctor () [0x00000] in <00000000000000000000000000000000>:0
at pxr.UsdCsPINVOKE..cctor () [0x00000] in <00000000000000000000000000000000>:0
at pxr.PlugRegistry.GetInstance () [0x00000] in <00000000000000000000000000000000>:0
at Unity.Formats.USD.InitUsd.Initialize () [0x00000] in <00000000000000000000000000000000>:0
at Unity.Formats.USD.UsdzExporter.ExportUsdz (System.String usdzFilePath, UnityEngine.GameObject root) [0x00000] in <00000000000000000000000000000000>:0
at RuntimeExport.Update () [0x00000] in <00000000000000000000000000000000>:0
Rethrow as TypeInitializationException: The type initializer for 'pxr.UsdCsPINVOKE.SWIGExceptionHelper' threw an exception.
at pxr.UsdCsPINVOKE..cctor () [0x00000] in <00000000000000000000000000000000>:0
at pxr.PlugRegistry.GetInstance () [0x00000] in <00000000000000000000000000000000>:0
at Unity.Formats.USD.InitUsd.Initialize () [0x00000] in <00000000000000000000000000000000>:0
at Unity.Formats.USD.UsdzExporter.ExportUsdz (System.String usdzFilePath, UnityEngine.GameObject root) [0x00000] in <00000000000000000000000000000000>:0
at RuntimeExport.Update () [0x00000] in <00000000000000000000000000000000>:0
Rethrow as TypeInitializationException: The type initializer for 'pxr.UsdCsPINVOKE' threw an exception.
at pxr.PlugRegistry.GetInstance () [0x00000] in <00000000000000000000000000000000>:0
at Unity.Formats.USD.InitUsd.Initialize () [0x00000] in <00000000000000000000000000000000>:0
at Unity.Formats.USD.UsdzExporter.ExportUsdz (System.String usdzFilePath, UnityEngine.GameObject root) [0x00000] in <00000000000000000000000000000000>:0
at RuntimeExport.Update () [0x00000] in <00000000000000000000000000000000>:0
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
Unity.Formats.USD.InitUsd:Initialize()
Unity.Formats.USD.UsdzExporter:ExportUsdz(String, GameObject)
RuntimeExport:Update()
(Filename: currently not available on il2cpp Line: -1)
ApplicationException: Failed to create: C:\Users\felix\AppData\Local\Temp\zc0u9qvy.z7q\test.usdc
at USD.NET.Scene.Create (System.String filePath) [0x00000] in <00000000000000000000000000000000>:0
at Unity.Formats.USD.UsdzExporter.ExportUsdz (System.String usdzFilePath, UnityEngine.GameObject root) [0x00000] in <00000000000000000000000000000000>:0
at RuntimeExport.Update () [0x00000] in <00000000000000000000000000000000>:0
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 24 (22 by maintainers)
You don’t need to reference Unity code to fix this. Just create a private class with the same name in your assembly:
Reviving this – going to take another crack at it and try Tautvydas’ suggestion
Thanks for the precision, I was able to reproduce the issue. I took a look at the error, it’s definitely not my comfort/knowledge zone but we’ll keep track of the issue for further improvement.