UsdzExport doesn't work in Build when using IL2CPP, causes Exception (FTV-248)
See original GitHub issueWhen 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
Issue Analytics
- State:
- Created 4 years ago
- Comments:24 (22 by maintainers)
Top Results From Across the Web
Building il2cpp error when use dll exported from old ...
I tried the latest version of Unity 2020.3. 17f1, Unfortunately, il2cpp building still fails and the error is similar. Code (CSharp):
Read more >Unity iOS Build export IL2CPP support
I got below error while exporting game to iOS in unity 4.6.9. IL2CPP error for method 'System.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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