What InternalCall means ?

Unity use Mono as it’s CLR. In Mono, it use mono_add_internal_call method to register native function. For example, you have a class below:

namespace MyNamespace
{
    public class MyClass
    {
        [MethodImpl(MethodImplOptions.InternalCall)]
        public extern static void MyMethod();
    }
}

So to add internal call, you need to do something like this in your C++ code:

void MyMethod()
{
    /* Some code there */
    int a = 1;
}

void function_to_add_internal_call()
{
    mono_add_internal_call("MyNamespace.MyClass::MyMethod", MyMethod);
}

https://www.mono-project.com/docs/advanced/embedding

1 Like