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.

Unity 2018.1 and IL2CPP

See original GitHub issue

API doesnot work with Unity 2018.1 and IL2CPP enabled.

NotSupportedException: To marshal a managed method, please add an attribute named 'MonoPInvokeCallback' to the method definition.
  at Steamworks.NativeMethods.ISteamClient_SetWarningMessageHook (System.IntPtr instancePtr, Steamworks.SteamAPIWarningMessageHook_t pFunction) [0x00000] in <00000000000000000000000000000000>:0 
  at Steamworks.SteamClient.SetWarningMessageHook (Steamworks.SteamAPIWarningMessageHook_t pFunction) [0x00000] in <00000000000000000000000000000000>:0 
  at SteamManager.OnEnable () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.GameObject.AddComponent (System.Type componentType) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.GameObject.AddComponent[T] () [0x00000] in <00000000000000000000000000000000>:0 
  at SteamManager.get_Initialized () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00000] in <00000000000000000000000000000000>:0 
UnityEngine.GameObject:AddComponent(Type)
UnityEngine.GameObject:AddComponent()
SteamManager:get_Initialized()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
NotSupportedException: IL2CPP does not support marshaling delegates that point to generic methods.
  at System.Runtime.InteropServices.Marshal.StructureToPtr (System.Object structure, System.IntPtr ptr, System.Boolean fDeleteOld) [0x00000] in <00000000000000000000000000000000>:0 
  at Steamworks.Callback`1[T].BuildCCallbackBase () [0x00000] in <00000000000000000000000000000000>:0 
  at Steamworks.Callback`1[T]..ctor (Steamworks.Callback`1+DispatchDelegate[T] func, System.Boolean bGameServer) [0x00000] in <00000000000000000000000000000000>:0 
  at Steamworks.Callback`1[T].Create (Steamworks.Callback`1+DispatchDelegate[T] func) [0x00000] in <00000000000000000000000000000000>:0 
  at SteamSocialAPI+<Start>c__Iterator0.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00000] in <00000000000000000000000000000000>:0 
 
(Filename: currently not available on il2cpp Line: -1)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:98 (34 by maintainers)

github_iconTop GitHub Comments

6reactions
tomjohnstonecommented, May 15, 2018

Please find attached a callback system we implemented to overcome this issue (using Steamworks.NET):

https://gist.github.com/logadmin/9788c0b40ba967b087701268641c36ce

We also implemented some code for autogenerating this code if anyone’s interested.

4reactions
GMMancommented, Nov 20, 2018

Here’s what I came up with on Saturday: https://github.com/GMMan/Steamworks.NET/tree/il2cpp-callback-workaround-v1

I’ll see if I can get the other proposal implemented this week/end, and hold off on the PR until both are evaluated. Apologies ahead of the time for mismatching indentation; I tried to autoformat in VS but it made a mess, and VSCode apparently wasn’t set up for the correct indentation style when I was recopy-and-pasting the code…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unity 2018.1.0
Unity 2018.1.0 download and release notes. ... OSX: Added support for IL2CPP scripting backend for Mac Standalone player.
Read more >
IL2CPP Overview
IL2CPP enables Unity to pre-compile code for specific platforms. The binary file Unity produces at the end of this process already contains necessary...
Read more >
Build - IL2CPP errors With Unity version 2018.4.30f1
I have Unity version 2018.4.30f1 installed with unity hub, also ndk version android-ndk-r16b installed on android google developper, ...
Read more >
IL2CPP - Manual
IL2CPP (Intermediate Language To C++) is a Unity-developed scripting backend which you can use as an alternative to Mono when building projects for...
Read more >
Unity 2018.1 - Garry Newman
With IL2CPP you're compiling to a big dll. C++ can be decompiled, but not easily. And to be fair even if you handed...
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