Jump to content

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

Link to comment
Share on other sites

  • 4 weeks later...

Create an account or sign in to comment

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

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...