Definition
Platform Invocation Services lets managed code call exported functions in native libraries such as a Windows DLL or an Android .so. The declaration names the library and the function, and the runtime marshals the arguments across the boundary. Unity plugins for platform features and many native SDKs are used this way.
Relevance
P/Invoke is how a Unity plugin reaches platform code C# cannot call on its own, such as a Windows API, an Android library, or a native SDK. The library name and the function name are stored in the assembly metadata, and the runtime uses them to find the export when the method is first called.
Example
A mobile plugin ships a native library with an export named Play. The C# side declares DllImport("vibration") on a method of the same name. Calling Play from a script runs the native function, and the runtime converts the arguments on the way across.
Connected
Synonyms
Platform Invoke, DllImport