Version: 2020.3
独立平台
PC、Mac 和 Linux 独立平台构建设置

独立平台 Player 设置

本页面将详细介绍独立平台(Mac OSX、Windows 和 Linux)特有的 Player 设置。有关常规 Player 设置的描述,请参阅 Player 设置

Standalone Player settings
Standalone Player settings

您可以在以下部分找到这些属性的文档:

Icon

启用 Override for Standalone 设置可指定用于独立平台游戏的自定义图标。可以上传不同大小的图标来填充提供的每个方块。

Icon settings for the Standalone Player platforms
Icon settings for the Standalone Player platforms

Resolution and Presentation

使用 Resolution and Presentation 部分可在 ResolutionStandalone Player Options 部分中自定义屏幕的外观方面。

Resolution 部分

此部分可以自定义屏幕模式和默认大小。

Resolution section for the Standalone Player platforms
Resolution section for the Standalone Player platforms
属性 功能
Fullscreen Mode 选择全屏模式。此设置定义了启动时的默认窗口模式。
Fullscreen Window Set your app window to the full-screen native resolution of the display. Unity renders app content at the resolution set by script (or by user selection when the built application launches), but scales it to fill the window. When scaling, Unity adds black bars to the rendered output to match the aspect ratio chosen in the Player settings, so that the content isn’t stretched. This process is called letterboxing.
Exclusive Fullscreen (Windows only) 设置应用程序以保持对显示器的单独全屏使用。与 Fullscreen Window 不同,此模式会更改显示器的操作系统分辨率来匹配应用程序选择的分辨率。此选项仅在 Windows 上受支持;在其他平台上,设置将回退到 Fullscreen Window
Maximized Window (Mac only) 将应用程序窗口设置为操作系统的“最大化”定义。在 macOS 上,这意味着显示带有自动隐藏菜单栏和停靠栏的全屏窗口。此选项仅在 macOS 上受支持;在其他平台上,设置将回退到 Fullscreen Window
Windowed 将应用程序设置为标准的非全屏可移动窗口,其大小取决于应用程序分辨率。在此模式中,默认情况下可以调整窗口大小。要禁用此功能,请禁用 Resizable Window 设置。
Default Is Native Resolution 启用此选项可使游戏使用目标机器上使用的默认分辨率。如果 Fullscreen Mode 设置为 Windowed_,此选项不可用。| |Default Screen Width ||设置游戏画面的默认宽度(以像素为单位)。仅在 Fullscreen Mode 设置为 Windowed_ 时,此选项才可用。
Default Screen Height 设置游戏画面的默认高度(以像素为单位)。仅在 Fullscreen Mode 设置为 Windowed 时,此选项才可用。
Mac Retina Support 启用此选项可在 Mac 上启用高 DPI (Retina) 屏幕支持。Unity 默认情况下启用此功能。此功能可增强 Retina 显示屏上的项目显示效果,但在激活状态下会有点耗费资源。
Run In background 启用此选项可在应用程序失去焦点时让游戏继续运行(而不是暂停)。

Standalone Player Options 部分

此部分可以指定用户自定义屏幕的方式。例如,在此处可以决定用户是否可以调整屏幕大小以及可以同时运行多少个实例。

Standalone Player Options settings for the Standalone Player platforms
Standalone Player Options settings for the Standalone Player platforms
属性 功能
Capture Single Screen 启用此选项可确保全屏模式 (Fullscreen Mode) 下的独立平台游戏不会使多显示屏设置中的辅助显示屏变暗。Mac OS X 上不支持该功能。
Use Player Log 启用此选项可向日志文件写入调试信息。默认已启用。
警告:如果计划将应用程序提交到 Mac App Store,请禁用此选项。有关更多信息,请参阅发布到 Mac App Store
Resizable Window 启用此选项可允许用户调整独立平台播放器窗口的大小。
注意:如果禁用此选项,您的应用程序无法将 Fullscreen Mode 设置为 Windowed
Visible in Background 如果已将 Fullscreen Mode 设置为 _Windowed_,启用此选项可在背景中显示应用程序(在 Windows 中)。
Allow Fullscreen Switch 启用此选项可允许通过默认操作系统全屏按键在全屏模式和窗口模式之间切换。
Force Single Instance 启用此选项可将独立平台播放器限制为单个并发运行实例。
Supported Aspect Ratios 启用希望游戏启动时出现在分辨率对话框中的每个宽高比(只要用户的显示屏支持这些宽高比设置)。

Splash Image

通用 Splash Screen 设置上方,Player Settings 设置允许您为独立平台指定启动画面。

独立平台的 Splash Image Player 设置
独立平台的 Splash Image Player 设置
属性 功能
Virtual Reality Splash Image 选择要在虚拟现实显示中显示的自定义启动画面。

Other Settings

此部分可以自定义一系列选项,这些选项分为以下几组:

Rendering

使用这些设置可自定义 Unity 针对独立平台渲染游戏的方式。

Rendering Player settings for Standalone platforms
Rendering Player settings for Standalone platforms
属性 功能
Color Space 选择应该用于渲染的颜色空间,选项为:GammaLinear
请参阅线性渲染概述以了解这两者之间的区别。
Auto Graphics API for Windows 启用此选项可在运行游戏的 Windows 计算机上使用最佳图形 API。禁用此选项可添加和删除支持的图形 API。
Auto Graphics API for Mac 启用此选项可在运行游戏的 Mac 上使用最佳图形 API。禁用此选项可添加和删除支持的图形 API。
Auto Graphics API for Linux 启用此选项可在运行游戏的 Linux 计算机上使用最佳图形 API。禁用此选项可添加和删除支持的图形 API。
Color Gamut for Mac 可以为独立 Mac 平台添加或删除色域以用于渲染。单击加号 (+) 图标查看可用色域的列表。色域定义了给定设备(如监视器或屏幕)可以使用的所有颜色范围。sRGB 色域是默认色域(也是必需色域)。
Metal Editor Support 启用此选项可在 Unity Editor 中使用 Metal API,并释放更快速的着色器迭代以定位 Metal API。
Metal API Validation 如果需要调试着色器问题,请启用此选项。
注意:验证会提高 CPU 使用率,因此仅在进行调试时使用。
Metal Write-Only Backbuffer 允许在非默认设备方向上提高性能。此属性会在后缓冲区上设置 frameBufferOnly 标志,因此会阻止从后缓冲区的回读,但可实现一定程度的驱动程序优化。
Memoryless Depth 选择何时使用无记忆渲染纹理。无记忆渲染纹理在渲染时临时存储在区块内存中,而不是存储在 CPU 或 GPU 内存中。这可减少应用的内存使用量,但您无法读取或写入这些渲染纹理。
注意:只有 iOS、tvOS 10.0+ Metal 和 Vulkan 上支持无记忆渲染纹理。在其他平台上,渲染纹理受读/写保护并存储在 CPU 或 GPU 内存中。
Unused 从不使用无记忆帧缓冲区深度。
Forced 始终使用无记忆帧缓冲区深度。
Automatic 让 Unity 决定何时使用无记忆帧缓冲区深度。
Static Batching 启用此选项可使用静态批处理。
Dynamic Batching 启用此选项可在构建中使用动态批处理(默认情况下启用)。
注意:可编程渲染管线激活时,动态批处理无效,所以仅当 Scriptable Render Pipeline Asset Graphics 设置中未设置任何内容时,此设置才可见。
Compute Skinning 启用此选项可使用 DX11/ES3 GPU 计算蒙皮,这样可以释放 CPU 资源。
Graphics Jobs 启用此选项可指示 Unity 将图形任务(渲染循环)卸载到在其他 CPU 核心上运行的工作线程。此功能旨在减少主线程上 Camera.Render 所花费的时间,该时间通常成为瓶颈。
Lightmap Encoding 选择 Normal QualityHigh Quality 来设置光照贴图编码。此设置影响光照贴图的编码方案和压缩格式。
Lightmap Streaming Whether to use Mipmap Streaming for lightmaps. Unity applies this setting to all lightmaps when it generates them.
Note: To use this setting, you must enable the Texture Streaming Quality setting.
Streaming Priority Set the priority for all lightmaps in the Mipmap Streaming system. Unity applies this setting to all lightmaps when it generates them.
Positive numbers give higher priority. Valid values range from –128 to 127.
Frame Timing Stats 启用此属性可收集 CPU 和 GPU 帧时间统计信息。此属性与动态分辨率摄像机设置同时使用可确定应用程序是受 CPU 还是受 GPU 限制。
Use Display In HDR Mode(仅限 Windows) 选中此复选框可使游戏在运行时自动切换到 HDR 模式输出。这项设置仅适用于支持该功能的显示屏。如果显示屏不支持 HDR 模式,则游戏将在标准模式下运行。
Swap Chain Bit Depth 选择每个颜色通道中用于交换链缓冲区的位数。仅在启用 HDR 模式的情况下可用。
Bit Depth 10 Unity 将使用 R10G10B10A2 缓冲区格式和 Rec2020 原色(采用 ST2084 PQ 编码)。
Bit Depth 16 Unity 将使用 R16G16B16A16 缓冲区格式和 Rec709 原色及线性颜色(无编码)。

Vulkan Settings

启用 SRGB Write Mode 选项可允许 Vulkan 渲染器上的 Graphics.SetSRGBWrite() 在帧期间切换 sRGB 写模式。

Vulkan Player settings for Standalone platforms
Vulkan Player settings for Standalone platforms

注意:启用此功能可能会降低性能,尤其是基于区块的 GPU。

Mac App Store Options

Mac App Store Options
Mac App Store Options

有关设置这些选项的详细信息,请参阅将应用程序提交到 Mac App Store

发布到 Mac App Store

Use Player Log 属性允许将调试信息写入日志文件。这对于调查游戏问题很有用。但是,在为 Apple 的 Mac App Store 发布游戏时,需要禁用此功能,因为如果启用此功能,Apple 可能会拒绝您提交。有关日志文件的更多信息,请参阅 Unity 手册日志文件页面。

Use Mac App Store Validation 属性可启用 Mac App Store 的收据验证。如果启用此属性,则只有当游戏包含来自 Mac App Store 的有效收据时才会运行。将游戏提交给 Apple 以便在 App Store 上发布时,应使用此功能。这样可以防止用户不在购买游戏的计算机上而在另一台计算机上运行游戏。

请注意,此功能不实现任何强大的复制保护。特别需要说明的是,针对一个 Unity 游戏的任何潜在破解都将对所有其他 Unity 内容有效。因此,建议使用 Unity 的插件功能在此基础上实现您自己的收据验证代码。但是,由于 Apple 要求在显示屏幕设置对话框之前的最初阶段进行插件验证,因此您仍应启用此属性,以免 Apple 拒绝您的提交。

配置

Configuration settings for Standalone Player platforms
Configuration settings for Standalone Player platforms
设置 功能
Scripting Backend 选择要使用的脚本后端。脚本后端确定 Unity 如何在项目中编译和执行 C# 代码。
Mono 将 C# 代码编译为 .NET 公共中间语言 (CIL) 并使用公共语言运行时执行该 CIL。有关更多信息,请参阅 Mono Project 网站。
IL2CPP 将 C# 代码编译为 CIL,将 CIL 转换为 C++,然后将该 C++ 编译为本机机器代码,该代码在运行时直接执行。请参阅 IL2CPP 以了解更多信息。
API Compatibility Level Choose which .NET APIs you can use in your project. This setting can affect compatibility with 3rd-party libraries. However, it has no effect on Editor-specific code (code in an Editor directory, or within an Editor-specific Assembly Definition).
Tip: If you are having problems with a third-party assembly, you can try the suggestion in the API Compatibility Level section below.
.Net 4.x 兼容 .NET Framework 4(包括 .NET Standard 2.0 配置文件中的所有内容以及其他 API)。如果使用的库需要访问 .NET Standard 2.0 中未包含的 API,请选择此选项。生成更大的构建,并且任何可用的其他 API 不一定在所有平台上都受支持。有关更多信息,请参阅引用其他类库程序集
.Net Standard 2.0 兼容 .NET Standard 2.0。生成较小的构建并具有完整的跨平台支持。
C++ Compiler Configuration 选择在编译 IL2CPP 生成的代码时使用的 C++ 编译器配置。
注意:除非 Scripting Backend 设置为 IL2CPP_,否则此属性被禁用。| |Use incremental GC||使用增量式垃圾回收器,这种垃圾回收器将垃圾收集工作分布在多个帧上,因此可以在帧持续时间中减少与 gc 相关的峰值。| |Assembly Version Validation|| Indicates whether Mono validates types from a strongly-named assembly.| |Camera Usage Description|| Enter the reason for accessing the camera on the selected desktop device.| |Microphone Usage Description|| Enter the reason for accessing the microphone on the selected desktop device.| |Active Input Handling|| 选择您希望如何处理来自用户的输入。 | ||Input Manager| 使用传统的 Input 设置。 | ||Input System (New)| 使用较新的输入系统。输入系统作为此版本的预览包提供。要试用输入系统的预览版,请安装 InputSystem 包。| ||Both_
并排使用两个系统。

API Compatibility Level

You can choose your mono API compatibility level for all targets. Sometimes a 3rd-party .NET library uses functionality that’s outside of your .NET compatibility level. To understand what’s going on in such cases, and how to best fix it, try following these suggestions:

  1. Install ILSpy for Windows.
  2. Drag the .NET assemblies for the API compatilibity level that you are having issues with into ILSpy. You can find these under Frameworks/Mono/lib/mono/YOURSUBSET/.
  3. 拖入第三方程序集。
  4. 右键单击第三方程序集并选择 Analyze
  5. 在分析报告中,检查 Depends on 部分。此报告以红色突出显示第三方程序集所依赖的但在您选择的 .NET 兼容性级别中不可用的任何内容。

Script Compilation

独立平台播放器平台的 Script compilation 设置

Setting Function
Scripting Define Symbols Set custom compilation flags. For more details, see the documentation on Platform dependent compilation.
Additional Compiler Arguments Add entries to this list to pass additional arguments to the Roslyn compiler. Use one new entry for each additional argument.
To create a new entry, press the ‘+’ button. To remove an entry, press the ‘-’ button.
When you have added all desired arguments, click the Apply button to include your additional arguments in future compilations.The Revert button resets this list to the most recent applied state.
Suppress Common Warnings Disable this setting to display the C# warnings CS0169 and CS0649.
Allow ‘unsafe’ Code Enable support for compiling ‘unsafe’ C# code in a pre-defined assembly (for example, Assembly-CSharp.dll).
For Assembly Definition Files (.asmdef), click on one of your .asmdef files and enable the option in the Inspector window that appears.
Use Deterministic Compilation Disable this setting to prevent compilation with the -deterministic C# flag. With this setting enabled, compiled assemblies are byte-for-byte identical each time they are compiled.
For more information, see Microsoft’s deterministic compiler option documentation.
Enable Roslyn Analyzers Disable this setting to compile user-written scripts without Roslyn analyzer DLLs that might be present in your project.
Use Roslyn Reference Assemblies Disable this setting to the compiler not to skip compilation reference assemblies when the metadata of the assembly does not change.

Optimization

独立平台播放器平台的 Optimization 设置
独立平台播放器平台的 Optimization 设置
属性 功能
Prebake Collision Meshes 启用此选项可在构建时将碰撞数据添加到网格。
Keep Loaded Shaders Alive 启用此选项可防止卸载着色器。
Preloaded Assets 设置一个资源数组,供播放器在启动时加载。
要添加新资源,请增大 Size 属性的值,然后在出现的新 Element 框中设置对要加载的资源的引用。
Strip Engine Code(仅限 IL2CPP) 指定 Unity Linker 工具是否删除项目不使用的 Unity 引擎功能的代码。
Managed Stripping Level 定义 Unity 剥离未使用的托管 (C#) 代码时的激进程度。
当 Unity 构建游戏或应用程序时,Unity Linker 进程可以从项目中使用的托管动态链接库中剥离未使用的代码。剥离代码可以使生成的可执行文件显著减小,但有时可能会错误地删除实际在使用的代码。此设置允许您选择 Unity 删除未使用代码时应采取的激进程度。
Disabled_(仅限 Mono)|不要剥离任何代码。(使用 IL2CPP 时会始终启用托管代码剥离。)| ||Normal|删除无法访问的托管代码以减少构建大小和 Mono/IL2CPP 构建时间。| ||Aggressive_(实验性功能) Normal 选项更激进地删除代码。代码大小进一步降低,但这种额外降低可能会产生副作用。例如,某些方法可能在调试器中不再可见,并且可以剥离通过反射访问的代码。您可以创建自定义 link.xml 文件以保留特定的类和方法。有关更多信息,请参阅使用 IL2CPP 进行托管字节码剥离
Enable Internal profiler (Deprecated) 启用此选项可在测试项目时从 Android SDK 的 adblogcat 输出中获取设备中的性能分析器数据。此选项适用于开发版。
Script Call Optimization 选择如何在运行时选择性地禁用异常处理以提高速度。有关详细信息,请参阅 iOS 优化
Slow and Safe 使用完整的异常处理(使用 Mono 脚本后端时会对设备的性能有一些影响)。
Fast but no Exceptions 不为设备上的异常提供数据(使用 Mono 脚本后端时游戏运行速度更快)。
注意:将此选项与 IL2CPP 脚本后端 一起使用不会影响性能;但是,使用此选项可以避免发布版本中出现未定义的行为。
Vertex Compression 设置每个通道的顶点压缩。例如,可以为除位置和光照贴图 UV 之外的所有内容启用压缩。为每个导入对象设置的整个网格压缩将覆盖在对象上设置顶点压缩。所有其他内容都遵循这些顶点压缩设置。
Optimize Mesh Data 启用此选项可从网格中删除应用于网格的材质不需要的所有数据(例如切线、法线、颜色和 UV)。

Logging

选择在特定上下文中允许的日志记录类型。

独立平台播放器平台的 Logging 设置
独立平台播放器平台的 Logging 设置

选中运行脚本时 (ScriptOnly)、始终 (Full) 或从不 (None) 条件下对应于每个 Log Type(ErrorAssertWarningLogException)的复选框。

Legacy

启用 Clamp BlendShapes (Deprecated) 选项可在 SkinnedMeshRenderers 中钳制混合形状权重的范围。

Legacy settings for Standalone Player platforms
Legacy settings for Standalone Player platforms



独立平台
PC、Mac 和 Linux 独立平台构建设置