The process to call code in native plug-insA set of code created outside of Unity that creates functionality in Unity. There are two kinds of plug-ins you can use in Unity: Managed plug-ins (managed .NET assemblies created with tools like Visual Studio) and Native plug-ins (platform-specific native code libraries). More info
See in Glossary for Android is the same as standard native plug-insA platform-specific native code library that is created outside of Unity for use in Unity. Allows you can access features like OS calls and third-party code libraries that would otherwise not be available to Unity. More info
See in Glossary.
Note: If you use individual C/C++ source files as plug-ins, use __Internal
as the plug-in name in the DllImport attribute.
It’s best practice to wrap all native plug-in method calls with an additional C# code layer that:
The AndroidNativePlugin.unitypackage zip file contains a simple example of a native code plug-in distributed as a Unity package.
The sample shows how to invoke C++ code from a Unity application. The package includes a sceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
See in Glossary which displays the sum of two values as calculated by a native plug-in. To compile the plug-in, use Android NDK. For information on how to install Android NDK via the Unity Hub, see Android environment setup.
To install the sample:
AndroidNativePlugin.unitypackage
file.AndroidNativePlugin.unitypackage
file.