# Mono 概述

> Mono is a stable, mature .NET runtime that provides a managed environment for the just-in-time (JIT) compilation of your C# code.

**Mono 脚本后端**在运行时使用一种称为即时编译 (JIT) 的技术编译代码。Unity 使用开源 [Mono 项目](https://www.mono-project.com/)的[分叉](https://github.com/Unity-Technologies/mono)。

某些平台不支持 JIT 编译，因此 Mono 后端并非适用于所有平台。其他平台支持 JIT 和 Mono，但不支持提前编译 (AOT)，因此无法支持 [IL2CPP 后端](/engine/6000.0/manual/scripting/compilation-and-code-reload/backends/il2cpp.md)。当平台可以同时支持两个后端时，默认为 Mono。有关更多信息，请参阅[脚本限制](/engine/6000.0/manual/scripting/compilation-and-code-reload/backends/restrictions.md)。

Mono 支持托管代码的调试。想了解更多相关信息，请参阅[在 Unity 中调试 C# 代码](/engine/6000.0/manual/scripting/debugging-and-diagnostics/managed-code-debugging.md)。

## 使用 Mono 来构建项目

您可以通过以下两种方法的其中一种来更改 Unity 用于构建应用程序的脚本后端：

* 通过编辑器中的**播放器设置** (Player Settings) 菜单。执行以下步骤可通过**播放器** (Player) 设置菜单更改脚本后端：

  1. 转到**编辑** (Edit) > **项目设置** (Project Settings)。
  2. 选择**播放器**可在 [Inspector](/engine/6000.0/manual/unity-editor/using-the-editor/using-the-inspector.md) 中打开当前平台的[播放器](/engine/6000.0/manual/unity-editor/editor-features/comp-manager-group/class-player-settings.md)设置。
  3. 在**其他设置**子菜单下，导航到**配置** (Configuration) > **脚本后端** (Scripting Backend)。
  4. 选择 **Mono**。

* 通过编辑器脚本 API。使用 [PlayerSettings.SetScriptingBackend](/engine/6000.0/script-reference/unity-editor/player-settings/set-scripting-backend.md) 属性可更改 Unity 使用的脚本后端。


**播放器 (Player) 设置的配置 (Configuration) 部分:**
![](/api/media?file=/engine/6000.0/media/images/backend-mono.png)

要开始构建过程，请打开**构建配置文件**窗口（菜单：**文件** > **构建配置文件**），然后选择**构建**。

Mono 和 IL2CPP 脚本后端都需要针对每个目标平台重新构建。例如，要同时支持 Android 和 iOS 平台，需要构建两次应用程序并生成两个二进制文件，一个用于 Android，另一个用于 iOS。

## 其他资源

* [Unity .NET 功能](/engine/6000.0/manual/scripting/environment-and-tools/overview-of-dot-net-in-unity.md)
* [构建配置文件](/engine/6000.0/manual/unity-editor/editor-features/build-settings.md)
