Version: 2023.2
程序集定义文件格式
Import and configure plug-ins

Plug-ins

In Unity, you normally use scripts to create functionality, but you can also include code created outside Unity in the form of a plug-in. 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, see 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 see 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:


  • 2018–03–19 页面已修订

  • 从 2018.1 开始,MonoDevelop 由 Visual Studio 取代

程序集定义文件格式
Import and configure plug-ins