Jump to content
 
Fireproof

Unity IL2CPP errors with the DeepLink API

Recommended Posts

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>:0

If 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

Share this post


Link to post
Share on other sites

@Fireproof Thanks for re-reporting this. Can you let me know what version of Unity you're using?

Share this post


Link to post
Share on other sites

Please sign in to comment

You need to be a member in order to leave a comment

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...