Version: 2021.2
2D 和 3D 模式设置
Shortcuts Manager

Preferences

Unity 提供了许多偏好设置,用于自定义 Unity 编辑器的行为。

要访问 Preferences 窗口,请从 Unity 的主菜单中选择 Edit > Preferences (Windows) 或 Unity > Preferences (macOS)。可使用以下偏好设置类别:

浏览 Preferences 窗口

使用搜索框可以筛选设置类别列表,并在右侧的详细信息面板中突出显示关键字。

General

General 偏好设置可用于自定义 Unity 的总体使用方式。

Preferences 窗口中的 General 范围
Preferences 窗口中的 General 范围
属性 功能
Load Previous Project on Startup 启用此设置可在启动时始终加载上一个项目。
Disable Editor Analytics (Pro only) 启用此设置可禁止 Editor 自动将信息发送回 Unity。
Show Asset Store search hits 启用此设置可在 Project Browser 中显示 Asset Store 中的免费/付费资源数量。
Script Changes While Playing 选择在 Editor 中运行游戏时脚本发生更改的情况下 Unity 采取的行为。
Recompile And Continue Playing 重新编译脚本并继续运行场景。这是默认行为,但如果脚本依赖于任何不可序列化的数据,可能需要更改默认行为。
Recompile After Finished Playing 推迟重新编译,直到手动停止场景,从而避免发生任何中断。
Stop Playing And Recompile 立即停止场景的重新编译,允许您快速重新启动测试。
Code Optimization On Startup 选择当 Unity 编辑器启动时是否将代码优化模式设置为 DebugReleaseDebug 模式使您可以附加外部调试器软件,但在编辑器中以运行模式运行项目时会导致 C# 性能下降。Release 模式使您可以以较高的 C# 性能在编辑器中以运行模式运行项目,但无法附加外部调试器软件。有关更多信息,请参阅代码优化模式
Editor Theme 选择要在 Unity Editor 中使用的皮肤。此设置仅适用于 Plus 和 Pro 版 Unity 订阅。
Personal 使用浅灰色背景和黑色文本。
Professional 使用深灰色背景和白色文本。
Editor Font 选择要在 Unity Editor 中显示的字体。默认字体为 Inter。
Enable Alpha Numeric Sorting 启用此设置可在 Hierarchy 窗口的右上角显示一个按钮,用于在变换 (Transform) 排序(默认)和字母数字 (Alphanumeric) 排序之间切换。
Create Objects at Origin 启用此设置可在世界坐标 0,0,0 处实例化新的 3D 对象。否则,Unity 使用 Scene 轴心(在 Scene 视图摄像机前面)。
Interaction Mode 指定 Editor 在最长空闲多长时间之后更新。一帧结束后,Editor 将等待指定的时间,直到下一帧开始。

这样可以调节 Editor 的性能,并减少 CPU 资源消耗和功耗。

例如,如果要测试 Editor 的性能,请将此属性设置为 No Throttling。如果要降低功耗(例如,延长笔记本电脑的电池续航时间),请将此属性设置为调速模式之一。

在调速模式下,如果与 Editor 进行交互(例如,通过在 Scene 视图中平移),Editor 将停止空闲模式。

注意:在运行模式下,Unity 会忽略您使用此偏好设置应用的任何调速模式。除非在 Game 视图中启用了 VSync 选项,或者将 Application.targetFrameRate 设置为 –1 以外的值,否则 Editor 会尽快更新。
Default 每次勾选时,Editor 最多闲置 4 毫秒。如果一帧用时 5 毫秒或更长时间,则 Editor 完全不会空闲,并且下一帧会自动开始。
No Throttling 每一帧结束时,下一帧立即开始。Editor 永远不会等待,并且会尽快更新。

此模式消耗大量 CPU 资源。如果使用的是笔记本电脑,可能会导致电池电量快速耗尽。
Monitor Refresh Rate Editor 空闲的最长时间是监视器的帧率(以毫秒为单位)。对于大多数监视器,此值为 16 毫秒。
Custom 指定应用程序可以处于空闲状态的最长时间。

选择此选项时,将显示 Frame Throttling (milliseconds) 属性。
Frame Throttling (milliseconds) Interaction Mode 设置为 Custom 时,此属性指定 Editor 可以在帧之间处于空闲状态的时间长度。该值可介于 0 到 33 毫秒之间。0 等效于将 Interaction Mode 设置为 No Throttling

2D

使用 Max Sprite Atlas Cache Size (GB) 偏好设置可设置精灵图集缓存文件夹的最大大小。Unity 会尽可能使此文件夹的大小低于此水平。

Preferences 窗口中的 2D 范围
Preferences 窗口中的 2D 范围

Analysis

The Analysis preferences let you define settings for the Profiler.

Preferences 窗口中的 Analysis 范围
Preferences 窗口中的 Analysis 范围
属性 功能
Frame count 设置性能分析器要捕获的最大帧数。您可以将此数字设置在 300 到 2,000 之间。
Show stats for ‘current frame’ 默认情况下,选择 Current Frame 按钮并进入 Current Frame 模式时,帧指示线不会随当前帧统计信息显示相关注释。这是因为统计信息注释可能导致难以实时查看数据。要显示注释,请启用此设置。
Default recording state 选择性能分析器应该在哪种记录状态下打开。可选择 EnabledDisabledRemember。Enabled 保持 Record 按钮在会话之间启用,而 Disbled 则将其禁用,无论您在性能分析会话期间是否将其打开或关闭。Remember 状态会记住您是否启用或禁用了 Record 按钮,并在您下次打开 Profiler 窗口时保持其上次的状态。
Default editor target mode 选择 Attach to Player 下拉选单的默认目标模式。可选择 PlaymodeEditor

Asset Pipeline

Asset Pipeline scope on the Preferences window
Asset Pipeline scope on the Preferences window
属性 功能
Auto Refresh Enable this setting to import Assets automatically as they change.
Compress Textures on Import Disable this setting to skip texture compression during import (textures will be imported into uncompressed formats).
Verify Saving Assets Enable this setting if you wish to verify which Assets to save individually. A dialog is shown any time Unity saves any assets.
Unity Accelerator (Cache Server)
Default Mode Define whether the Cache Server is enabled or disabled by default. You can override this per Project in the Unity Editor settings. For more information, see Unity Accelerator.
Default IP address 设置要使用的缓存服务器的默认 IP 地址。可以在 Unity Editor 设置中根据每个项目覆盖此设置。
Check Connection 单击此按钮尝试连接到远程缓存服务器。

Colors

Colors 偏好设置允许您选择 Unity 在显示各种用户界面元素时使用的颜色。

Preferences 窗口中的 Colors 范围
Preferences 窗口中的 Colors 范围

Diagnostics

When you report a problem to Unity, the Unity Support Team might ask you to turn on diagnostic switches to help them identify the cause. Running diagnostics on an application, whether in the Editor or a player, impacts performance and user experience. You should only run diagnostics when the Unity Support Team asks for them.

If diagnostic switches are active in your application, Unity shows a warning in the console. To reset switches, in the Diagnostics tab, click Reset all.

If an active diagnostic switch prevents the Unity Editor from opening, use the --reset-diagnostic-switches parameter to reset all switches from the command line. For more information on using command line arguments at launch, see Command line arguments.

External Tools

使用 External Tools 偏好设置可设置用于编写脚本、处理图像和进行源代码控制的外部应用程序。

Preferences 窗口中的 External Tools 范围
Preferences 窗口中的 External Tools 范围
属性 功能
External Script Editor 选择 Unity 应使用哪个应用程序来打开脚本文件。Unity 会自动将正确的参数传递给内置支持的脚本编辑器。Unity 内置支持 Visual Studio Community、Visual Studio Code (VSCode) 和 JetBrains Rider。Open by file extension 选项会将设备的默认应用程序用于打开相关的文件类型。如果没有默认应用程序可用,设备会打开一个窗口,提示选择用于打开文件的应用程序。
External Script Editor Args 该字段控制打开文件时 Unity 可以发送给代码编辑器的参数。$(File)$(Line)$(Column) 参数将文件名、行号和列号传递给外部代码编辑器。代码编辑器会使用这些参数打开正确的文件,并且光标位于正确的位置。例如,如果在 Unity 控制台中双击错误消息,则 Unity 会将这些参数从该错误消息传递到外部编辑器,然后由外部编辑器打开正确的文件,并定位到发生错误的位置。

可以手动编辑此字段以自定义 Unity 发送到外部代码编辑器的参数。单击 Reset argument 按钮可将此字段重置为其默认设置,如以上截屏所示。
Generate all .csproj files. 启用此设置可生成所有 .csproj 文件。代码编辑器使用 .sln 和 .csproj 文件来访问有关项目的数据。.csproj 文件以 XML 格式存储描述性数据或元数据。此数据可能包括版本信息、平台要求、构建文件或数据库设置。

当这些文件存在时,代码编辑器可以使用其中包含的数据来提供有用的功能,例如突出显示潜在的编译错误。启用此设置可指示 Unity 在项目中尽可能创建 .csproj 文件。
Extensions handled
(仅当在 External Script Editor 中选择 Rider 或 Visual Studio Code 时才可用)
此字段确定外部脚本编辑器 (External Script Editor) 打开的文件类型。此字段预先填充了脚本编辑器默认打开的文件列表。要将其他文件类型添加到此列表,请键入文件扩展名,并用分号分隔每个扩展名。
Add .unityproj’s to .sln
(已弃用)
此设置永久无效,因为已经弃用 Unityscript(这是生成 .unityproj 文件的脚本语言)。
Editor Attaching 启用此设置可允许外部代码编辑器调试在 Unity Editor 中运行的脚本。如果禁用此选项,则无法通过将脚本调试器附加到 Unity 来调试脚本。有关调试的更多信息,请参阅在 Unity 中调试 C# 文档。

注意:更改此设置时,需要重新启动 Unity 才能使更改生效。
Image application 选择希望 Unity 使用哪个应用程序来打开图像文件。
Revision Control Diff/Merge 选择希望 Unity 使用哪个应用程序解决源代码控制代码仓库中的文件差异。Unity 在工具的默认安装位置检测这些工具。在 Windows 上,Unity 会检查 TortoiseMerge、WinMerge、PlasticSCM Merge 和 Beyond Compare 4 的注册表项。

有关更多信息,请参阅下面的 Revision Control Diff/Merge 部分。

Revision Control Diff/Merge

Unity 目前支持以下工具:

  • SourceGear DiffMerge
  • TkDiff
  • P4Merge
  • TortoiseMerge
  • WinMerge
  • PlasticSCM Merge
  • Beyond Compare 4

注意:这些是 Unity 默认未包含的第三方工具。必须单独下载和安装这些工具。

要设置自定义修订工具,请按照下列步骤操作:

  1. Revision Control Diff/Merge 下拉列表中,选择 Custom Tool
  2. 输入自定义工具的安装文件夹的路径。在 Mac 上,应指向该工具的安装文件夹中的 Contents / MacOS 文件夹。
  3. 输入有关双向差异、三向差异和合并的参数。

要指定修订工具中的文件布局,请使用以下参数:

属性 功能
#LTITLE 左侧标题
#RTITLE 右侧标题
#ATITLE 上级标题
#LEFT 左侧文件
#RIGHT 右侧文件
#ANCESTOR 上级文件
#OUTPUT 输出文件
#ABSLEFT 左侧文件的绝对路径
#ABSRIGHT 右侧文件的绝对路径
#ABSANCESTOR 上级文件的绝对路径
#ABSOUTPUT 输出文件的绝对路径

例如:

SourceGear DiffMerge
SourceGear DiffMerge
P4Merge
P4Merge

GI Cache

The Global Illumination (GI) system uses a cache on each computer to store intermediate files used to pre-compute real-time Global Illumination. All projects on the computer share the cache.

Preferences 窗口中的 GI Cache 范围
Preferences 窗口中的 GI Cache 范围
属性 功能
Maximum Cache Size (GB) 使用滑动条来设置最大的 GI 缓存文件夹大小。Unity 会尽量将 GI 缓存文件夹大小保持低于此数字。Unity 会定期删除未使用的文件以创建更多的空间(首先删除最老的文件)。这是一项自动过程,不需要您执行任何操作。
注意:如果当前场景使用了 GI 缓存中的所有文件,请增加缓存大小。否则,在烘焙时会进行非常耗费资源的重新计算。当场景非常大或缓存太小时,就会发生这种情况。
Custom cache location 启用此选项可允许设置 GI 缓存文件夹的自定义位置。默认情况下,GI 缓存存储在 Caches 文件夹中。所有项目共享缓存文件夹。
提示:将 GI 缓存存储在 SSD 驱动器上可以在烘焙过程受 I/O 限制的情况下加速进行烘焙。
Cache Folder Location 单击 Browse 按钮可指定缓存的位置。
Cache compression This option enables Unity to compress datafiles in the GI cache to use less hard drive space. The datafiles are LZ4-compressed by default, and the naming scheme is a hash and a file extension. Unity computes the hashes based on the inputs to the lighting system, so changing any of the following settings, properties or assets can lead to lighting recomputation:
- Materials (Textures, Albedo, Emission)
- Lights
- Geometry
- Static flags
- Light Probe groups
- Reflection probes
- Lightmap Parameters
Tip: If you need to access the raw Enlighten Realtime Global Illumination data, disable Cache Compression and clear the cache.
Clean Cache 使用此按钮可清除缓存目录。
在 Editor 运行时手动删除 GI Cache 目录是不安全的做法。这是因为 Editor 在启动时会创建 GiCache 文件夹,并且不断引用这些文件。Clean Cache 按钮可确保 Editor 在删除磁盘上的文件之前释放对这些文件的所有引用。
Cache size is 显示当前缓存大小。
Cache Folder Location 显示当前缓存文件夹的位置。

Scene View

使用 Scene View 偏好设置自定义对象在编辑时的放置和可见性。

Preferences 窗口中的 Scene View 范围
Preferences 窗口中的 Scene View 范围
属性 功能
Create Objects at Origin 启用以在原点创建新对象(与 Scene 轴心相反)。默认禁用。
Create Objects with Constrained Proportions Defines the default behavior for Scale in the Transform component.
If enabled, when you adjust the value of a scale axis, the other values adjust proportionately.
Line Thickness 设置您的转换工具的线条粗细。
Enable filtering while searching 启用可使 Scene 视图中的任何不匹配项变灰。默认启用。
Enable filtering while editing LOD groups 启用可在编辑 LOD 组时使场景中的其他对象变灰。默认启用。

Search

You can set Search preferences from the Unity Preferences window (menu: Edit > Preferences).

Tip: You can also access the Search preferences in any of the following ways:

  • Enter ? (question mark) in the search field and select Open Search Preferences from the results.
  • From More Options (:) in the top-left of the Search window, select Preferences.

preferences page
Search Preferences

Setting: 功能:
Track the current selection in the search Enable this setting to execute the SearchProvider.trackSelection callback each time the Search selection changes.

The callback pings Assets in the Project window or Hierarchy window, which can slow Search navigation in large Projects.
Generate an asset preview thumbnail for found items Enable this setting to display thumbnails for items that are currently visible in the results pane of the Search window.

When you disable this setting, Search displays a generic icon. This is useful in large Projects, where generating icons can slow Search navigation.
Select the typing debounce threshold The debouncing threshold is the time the system waits for the user to finish typing before executing the search.
Provider Settings
A [Provider Toggles] Enable and disable providers. When you disable a provider, Search ignores it when executing searches.
B [Provider Order] Use these settings to modify the order in which search items are shown on the screen. All items of a given provider priority appear before any lower priority items.
C [Default Actions] Use these settings to choose the default actions to execute when you select (for example, double-click) an item in the search results.
Reset Priorities Resets all providers to their default on/off state and priority.
Search Engines Set the search fields in the Object Selector, Project, and Scene to one of the available search engines.

Legacy - The original search functionality.
Default - The latest version of Search for Unity (formerly QuickSearch).

UI Scaling

UI Scaling 偏好设置可定义如何在 Unity Editor 中缩放 UI 文本和图标。

Preferences 窗口中的 UI Scaling 范围
Preferences 窗口中的 UI Scaling 范围
属性 功能
Use default desktop setting 启用此设置可使用计算机的默认设置来缩放 UI 文本和图标。
Current scaling 显示当前缩放值。
Use custom scaling value 覆盖缩放值。

包的自定义偏好设置

一些 Asset Store 包或 Unity 包会将自己的自定义偏好设置添加到 Preferences 窗口中。通常,它们使用包名称作为偏好设置类别。在以下示例中,可以看到 Cinemachine 包的偏好设置:

范围列表中显示特定于包的偏好设置
范围列表中显示特定于包的偏好设置

有关特定包的偏好设置的信息,请参阅该包的文档。本部分仅包含标准 Unity 偏好设置的文档。


  • 2020–05–04 页面已修订

  • 在 2019.3 版中添加了 Interaction Mode 偏好设置

  • 2019.3 版中添加了 Analysis 和 UI Scaling 选项卡,并删除了 Grid Brush 和 Tile Palette 选项卡

  • 2019.1 版中为 External Tools 部分添加了 Gradle for Android 选项。

  • 2019.1 版中删除了关键字并且为 Tile Palette 偏好设置添加了更多选项。NewIn20191

  • 在 2018.3 版中添加了子游戏对象的选择轮廓线颜色偏好设置

  • 为 Unity 2018.3 新增了统一设置和其他更新

  • 在 Unity 2018.2 中添加了 Script Changes While Playing 和 Device To Use 下拉菜单

  • 在 2018.1 版中更新了外部脚本编辑器的列表

2D 和 3D 模式设置
Shortcuts Manager