Fireproof
-
Posts
2 -
Joined
-
Last visited
Content Type
Profiles
Forums
Gallery
Blogs
Events
Store
Downloads
Posts posted by Fireproof
-
-
I've found that if you try to use the GoToStore function in Unity with IL2CPP, then in a build it will fail with this:
NotSupportedException: IL2CPP does not support marshaling delegates that point to instance methods to native code.
at Viveport.Deeplink.GoToStore (Viveport.StatusCallback2 callback, System.String viveportId) [0x00000] in <00000000000000000000000000000000>:0If you attempt to build the DeepLink demo that ships with the SDK, you get the same error.
I put some code together which avoids using the official C# wrapper, and calls into the dll direct. Here it is, in case anyone else has the same problem in future:
Disclaimer! While I can confirm that this doesn't report errors and does open Viveport, I don't know if it actually opens the correct app since ours isn't listed yet.
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void Callback2(int result, [MarshalAs(UnmanagedType.LPStr)] string message); [DllImport("viveport_api64", EntryPoint = "IViveportDeeplink_GoToStore", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)] private static extern void GoToStore(Callback2 callback, string appId); [AOT.MonoPInvokeCallback(typeof(Callback2))] static void GotoStoreHandlerMarhsalled(int result, [MarshalAs(UnmanagedType.LPStr)] string message) { Debug.Log($"Handled! {result.ToString()}, {message}"); } public override void GoToStorePage() { GoToStore(GoToStoreHandler, "APP_ID_HERE"); }
This is basically the same problem that was reported two years ago here, so it's a shame it hasn't been fixed yet! https://forum.vive.com/topic/4538-viveport-sdk-and-unitys-il2cpp-build-option/?tab=comments#comment-4545
Unity IL2CPP errors with the DeepLink API
in Viveport SDKs and Downloads
Posted
@Corvus Thanks for the response! We're using 2018.4.14f1.