natbro / UnityPlugin

example of callbacks, recurring callbacks, buffer marshaling from native-code to Unity/C#
102 stars 9 forks source link

Doesn't work with IL2CPP #2

Open d4rkd3v1l opened 7 years ago

d4rkd3v1l commented 7 years ago

Sadly this approach isn't working anymore with unity's il2cpp compiler. So it seems like the only remaining option is unity's SendMessage, which is just a pain in the ass?

NotSupportedException: IL2CPP does not support marshaling delegates that point to instance methods to native code. at UnityPlugin.Awake () [0x00000] in :0

karsnen commented 6 years ago

Will this help?

https://answers.unity.com/questions/1229036/callbacks-from-c-to-c-are-not-working-in-540f3.html

s-hocking commented 6 years ago

Yep, for anyone else reading this, the solution is to make your C# callback delegate methods static.

caochao commented 5 years ago

so sad, I just want to pass a non-static c# callback to c++, but it can't