question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UsdzExport doesn't work in Build when using IL2CPP, causes Exception (FTV-248)

See original GitHub issue

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 

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:24 (22 by maintainers)

github_iconTop GitHub Comments

3reactions
TautvydasZilyscommented, Feb 21, 2020

which means adding the special mono tag to that code is not immediately possible…

You don’t need to reference Unity code to fix this. Just create a private class with the same name in your assembly:

class MonoPInvokeCallbackAttribute : Attribute
{
}
1reaction
jcowlescommented, Apr 4, 2020

Reviving this – going to take another crack at it and try Tautvydas’ suggestion

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found