Calling a C# function from C++
This is a simple example of calling a C# function from C++.
First you need to send the function pointer from C#:
using CppInator.Runtime;
delegate void MyFancyCallback(int number);
[DllImport("__Internal")]
static extern void CallMeBaby(MyFancyCallback callback);
void Start()
{
Native.Invoke(CallMeBaby, (MyFancyCallback)callback);
}
// MonoPInvokeCallback is required for the callback to work on iOS
[MonoPInvokeCallback(typeof(MyFancyCallback))]
void WhenCalled(int value)
{
Debug.Log("Omg, her number is: " + value);
}
Then you need to call the function from C++: