Version: Unity 6 (6000.0)
Language : English
Serialization best practice
Import and configure plug-ins

Integrating third-party code libraries (plug-ins)

In Unity, you normally use scriptsA piece of code that allows you to create your own Components, trigger game events, modify Component properties over time and respond to user input in any way you like. More info
See in Glossary
to create functionality, but you can also include code created outside Unity in the form of a plug-inA 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
. You can use two different kinds of plug-in in Unity:

  • Managed plug-ins: managed .NET assemblies you can create with tools like Visual Studio. They only contain .NET code, which means they can’t access any features that the .NET libraries do not support. For more information, refer to Microsoft’s documentation of managed code.
  • Native plug-ins: platform-specific native code libraries. They can access features like operating system calls and third-party code libraries that would otherwise be unavailable to Unity.

Managed code is accessible to the standard .NET tools that Unity uses to compile scripts. The only difference between managed plug-in code and Unity script code is that the plug-ins are compiled outside of Unity and so Unity might not be able to access the source. When using native plug-ins, Unity’s tools can’t access third-party code libraries in the same way that they can access the managed libraries. For example, if you forget to add a managed plug-in file to the project, you will get standard compiler error messages. Whereas, if you forget to add a native plug-in file to the project, you will only get an error report when you try to run the project.

The following pages explain how to create and use plug-ins in your Unity Projects:

Topic Description
Import and configure plug-ins Import and configure managed or native plug-ins.
Managed plug-insA managed .NET assembly that is created with tools like Visual Studio for use in Unity. More info
See in Glossary
Details on using managed plug-ins.
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
Details on using native plug-ins.
Building plug-ins for desktop platforms Deploy native code libraries for macOS, Windows, and Linux.
Low-level native plug-in interface Implement low-level rendering in your native plug-ins.

Additional resources

Serialization best practice
Import and configure plug-ins
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961