Version: 2021.2
Android 环境设置
Android 密钥库管理器

Android Player 设置

This page details the Player Settings for the Android platform. For a description of the general Player settings, see Player Settings.

Player Settings for Android.
Player Settings for Android.

有关属性的描述根据 Player UI 中的相应部分进行分组:

Icon

Use the Icon section to specify icons to represent your application on the device.

Icon settings for Android.
Icon settings for Android.
设置 描述
Adaptive Specify textures of various sizes to represent your application on devices running Android 8.0 (API level 26) or higher.
Round Specify textures of various sizes to represent your application on devices running Android 7.1 (API level 25) or higher.
Legacy Specify textures of various sizes to represent your application on devices running versions earlier than Android 7.1 (API level 25).

Resolution and Presentation

Use the Resolution and Presentation section to customize aspects of the screen’s appearance.

Resolution and Presentation settings for Android.
Resolution and Presentation settings for Android.
设置 描述
Fullscreen Mode Specifies how the window appears on the device. This sets the default window mode at startup.
Fullscreen Window The application window fills the full-screen native resolution of the device. To fill the full-screen window, Unity scales the application contents. To match the aspect ratio of the output device, Unity might add black bars to the rendered output so the content doesn’t stretch. This process is called letterboxing.In this mode, the navigation bar is always hidden.
Windowed The application uses a standard, non-full-screen, movable window. The size of the window depends on the application’s resolution. In this mode, the window is resizable by default. To disable this, disable Resizable Window.
Resizable Window Indicates whether the user can resize the application’s window.
This setting enables multi-window capabilities in your application on Android phones and tablets. For more information, see Google’s developer documentation.
Default Window Width The default width of the application window in pixels. This option is only available if the Fullscreen Mode is set to Windowed.
Default Window Height The default height of the application window in pixels. This option is only available if the Fullscreen Mode is set to Windowed.
Minimum Window Width The minimum width of the application window in pixels. This option is only available if the Fullscreen Mode is set to Windowed.
Minimum Window Height The minimum height of the application window in pixels. This option is only available if the Fullscreen Mode is set to Windowed.
Hide Navigation Bar Indicates whether to hide the navigation bar that appears at the top of the window.
Render outside safe area Indicates whether the application should use all available screen space to render, including areas of the display that are cut out (notched). For more information, see Android’s display cutout support documentation.
Optimized Frame Pacing Indicates whether Unity should evenly distribute frames for less variance in framerate. Enable this option to create a smoother experience.

Other Resolution and Presentation settings are grouped under the following sections:

Resolution Scaling

Use the Resolution Scaling section to customize settings relating to screen resolution scaling. Using a resolution lower than the device’s native resolution can improve performance and battery life.

Resolution Scaling settings for Android.
Resolution Scaling settings for Android.
设置 描述
Resolution Scaling Mode Specifies whether and how the application scales its resolution. You can set the scaling to be equal to or lower than the native screen resolution. Using a lower resolution can improve performance and battery life.
Disabled Doesn’t apply resolution scaling and the application renders to the device’s native screen resolution.
FixedDPI Applies resolution scaling using a target API. Use this to optimize performance and battery life or target a specific DPI setting.
Target DPI The resolution of the application. If the device’s native screen DPI is higher than this value, Unity downscales the application’s resolution to match this setting. To calculate the scale, Unity uses the following:
min(Target DPI * Factor / Screen DPI, 1)
Where Factor is the Resolution Scaling Fixed DPI Factor from Quality settings.Note: This option only appears when you set Resolution Scaling Mode to Fixed DPI.
Blit Type Controls whether to use a blit to render the final image to the screen. Using a blit is compatible with most devices but is usually slower than not using a blit.
Always Unity renders to an offscreen buffer and then uses a blit to copy the contents of the buffer to the device’s framebuffer. This is compatible with most devices but is usually slower than not using blit.
Never Unity renders to the framebuffer provided by the device’s operating system. If this fails, the application prints a one-time warning to the device log. This is usually faster than using blit, but it isn’t compatible with all devices.
Auto Unity renders to the framebuffer provided by the device’s operating system if possible. If this fails, Unity prints a warning to the device console and uses a blit to render the final image to the screen.

Supported Aspect Ratio

Use the Supported Aspect Ratio section to customize settings relating to which device aspect ratios to support.

Resolution Scaling settings for Android.
Resolution Scaling settings for Android.
设置 描述
Aspect Ratio Mode Specifies the largest aspect ratio the application supports. If the device’s aspect ratio is greater than this aspect ratio, Unity uses this aspect ratio for the application and adds black bars so the application doesn’t stretch..
Legacy Wide Screen (1.86) The application supports aspect ratios up to Android’s legacy wide-screen aspect ratio.
Native Aspect Ratio The application supports aspect ratios up to Android’s native aspect ratio.
Custom The application supports aspect ratios up to the aspect ratio you set in Up To.
  Up To The custom maximum aspect ratio.

This setting only appears when you set Aspect Ratio Mode to Custom.

Orientation

Use the Orientation section to customize settings relating to the orientation of the application on the device.

Orientation settings for Android.
Orientation settings for Android.

Default Orientation 下拉菜单中选择游戏的屏幕方向:

设置 描述
Default Orientation Specifies the screen orientation the application uses.

Note: Unity shares the value you set for this setting between Android and iOS.
Portrait The application uses portrait screen orientation where the bottom of the application’s window aligns with the bottom of the device’s screen.
Portrait Upside Down The application uses portrait screen orientation where the bottom of the application’s window aligns with the top of the device’s screen.
Landscape Right The application uses landscape screen orientation where the right side of the application’s window aligns with the bottom of the device’s screen.
Landscape Left The application uses landscape screen orientation where the right side of the application’s window aligns with the top of the device’s screen.
Auto Rotation The screen can rotate to any of the orientations you specify in the Allowed Orientations for Auto Rotation section.

Allowed Orientations for Auto Rotation

Use the Allowed Orientations for Auto Rotation section to specify which orientations the application supports when you set Default Orientation to Auto Rotation. This is useful, for example, to lock the application to landscape orientation but allow the user to switch between landscape left and landscape right.

This section only appears when you set Default Orientation to Auto Rotation.

Allowed Orientations for Auto Rotation settings for Android.
Allowed Orientations for Auto Rotation settings for Android.
设置 描述
Portrait Indicates whether the application supports portrait screen orientation where the bottom of the application’s window aligns with the bottom of the device’s screen.
Portrait Upside Down Indicates whether the application supports portrait screen orientation where the bottom of the application’s window aligns with the top of the device’s screen.
Landscape Right Indicates whether the application supports landscape screen orientation where the right side of the application’s window aligns with the bottom of the device’s screen.
Landscape Left Indicates whether the application supports landscape screen orientation where the right side of the application’s window aligns with the top of the device’s screen.

Other

The Resolution and Presentation section also contains the following general settings.

Other resolution and presentation settings for Android.
Other resolution and presentation settings for Android.
设置 描述
Use 32-bit Display Buffer Indicates whether the display buffer holds 32-bit color values instead of 16-bit color values. Enable this setting if you see banding, or need alpha values in post-processing effects. Some post-processing effects require this because they create Render Textures in the same format as the display buffer.
Disable Depth and Stencil Indicates whether to disable depth and stencil buffers.
Render Over Native UI Indicates whether to render on top of native UI on Android or iOS. For this setting to take effect, set your Camera’s Clear Flags to use a solid color with an alpha value lower than 1.
Show Loading Indicator Specifies if and how the loading indicator appears.
Don’t Show The loading indicator doesn’t appear.
Large A large loading indicator appears.
Inversed Large A large loading indicator appears with inversed color.
Small A small loading indicator appears.
Inversed Small A small loading indicator appears with inversed color.

Splash Image

Use the Virtual Reality Splash Image setting to select a custom splash image for Virtual Reality displays. For information on common Splash Screen settings, see Splash Screen.

Splash screen settings for virtual reality.
Splash screen settings for virtual reality.

以下是通用 Splash Screen 设置,可以设置特定于 Android 的 Static Splash Image 选项。

Splash screen settings for Android.
Splash screen settings for Android.
设置 描述
Image Specifies the texture that the application uses for the Android splash screen. The standard size for the splash screen image is 320x480.
Scaling Specifies how to scale the splash image to fit the devic’es screen.
Center (only scale down Draws the image at its native size unless it’s too large, in which case Unity scales the image down to fit.
Scale to Fit (letter-boxed) Scales the image so that the longer dimension fits the screen size exactly. Unity fills in the empty space around the sides in the shorter dimension in black.
Scale to Fill (cropped) Scales the image so that the shorter dimension fits the screen size exactly. Unity crops the image in the longer dimension.

Other Settings

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

渲染

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

Android 平台的 Rendering 设置
Android 平台的 Rendering 设置
Property Description
Color Space Choose which color space Unity uses for rendering: Gamma or Linear. See the Linear rendering overview for an explanation of the difference between the two.
Gamma: Gamma color space is typically used for calculating lighting on older hardware restricted to 8 bits per channel for the framebuffer format. Even though monitors today are digital, they might still take a gamma-encoded signal as input.
Linear: Linear color space rendering gives more precise results. When you select to work in linear color space, the Editor defaults to using sRGB sampling. If your Textures are in linear color space, you need to work in linear color space and disable sRGB sampling for each Texture.
Auto Graphics API Disable this option to manually pick and reorder the graphics APIs. By default this option is enabled, and Unity tries to use Vulkan. If the device doesn’t support Vulkan, Unity falls back to GLES3.2, GLES3.1 or GLES3.0. There are three additional checkboxes to configure the minimum OpenGL ES 3.x minor version: Require ES3.1, Require ES3.1+AEP and Require ES3.2.
Important: Unity adds the GLES3/GLES3.1/AEP/3.2 requirement to your Android manifest only if GLES2 is not in the list of APIs when Auto Graphics API is disabled. In this case only, your application does not appear on unsupported devices in the Google Play Store.
Color Gamut You can add or remove color gamuts for the Android platform to use for rendering. Click the plus (+) icon to see a list of available gamuts. A color gamut defines a possible range of colors available for a given device (such as a monitor or screen). The sRGB gamut is the default (and required) gamut. When targeting devices with wide color gamut displays, use DisplayP3 to utilize full display capabilities.
Multithreaded Rendering Enable this option to move graphics API calls from Unity�s main thread to a separate worker thread. This can help to improve performance in applications that have high CPU usage on the main thread.
Static Batching Enable this option to use Static batching.
Dynamic Batching Enable this option to use Dynamic Batching on your build (enabled by default).
Note: Dynamic batching has no effect when a Scriptable Render Pipeline is active, so this setting is only visible when nothing is set in the Scriptable Render Pipeline Asset Graphics setting.
Compute Skinning Enable this option to enable DX11/ES3 GPU compute skinning, freeing up CPU resources.
Graphics Jobs Enable this option to instruct Unity to offload graphics tasks (render loops) to worker threads running on other CPU cores. This is intended to reduce the time spent in Camera.Render on the main thread, which is often a bottleneck.
Texture compression format Choose between ASTC, ETC2 and ETC (ETC1 for RGB, ETC2 for RGBA). See texture compression format overview for more information on how to pick the right format.
See Texture compression settings for more details on how this interacts with the texture compression setting in the Build Settings.
Normal Map Encoding Choose XYZ or DXT5nm-style to set the normal map encoding. This affects the encoding scheme and compression format used for normal maps. DXT5nm-style normal maps are of higher quality, but more expensive to decode in shaders.
Lightmap Encoding Choose Normal Quality or High Quality to set the lightmap encoding. This setting affects the encoding scheme and compression format of the lightmaps.
Lightmap Streaming Enable this option to load only the lightmap mip maps as needed to render the current game Cameras. This value applies to the lightmap textures as they are generated.
Note: To use this setting, you must enable the Texture Streaming Quality setting.
  Streaming Priority Set the lightmap mip map streaming priority to resolve resource conflicts. These values are applied to the light map textures as they are generated.
Positive numbers give higher priority. Valid values range from –128 to 127.
Frame Timing Stats Enable this property to gather CPU and GPU frame time statistics. Use this together with the Dynamic Resolution camera setting to determine if your application is CPU or GPU bound.
Virtual Texturing Indicates whether to enable Virtual Texturing.
Note: Virtual Texturing isn’t compatible with Android.
Shader precision model Controls the default precision of samplers used in shaders. See Shader data types and precision for more details.
360 Stereo Capture Indicates whether Unity can capture stereoscopic 360 images and videos. For more information, see Stereo 360 Image and Video Capture.
Note: 360 stereoscopic capturing isn’t compatible with Android.

Vulkan Settings

Vulkan Player settings for the Android platform
Vulkan Player settings for the Android platform
Property Description
SRGB Write Mode Enable this option to allow Graphics.SetSRGBWrite() renderer to toggle the sRGB write mode during runtime. That is, if you want to temporarily turn off Linear-to-sRGB write color conversion, you can use this property to achieve that. Enabling this has a negative impact on performance on mobile tile-based GPUs; therefore, do NOT enable this for mobile.
Number of swapchain buffers Set this option to 2 for double-buffering, or 3 for triple-buffering to use with Vulkan renderer. This setting may help with latency on some platforms, but in most cases you should not change this from the default value of 3. Double-buffering might have a negative impact on performance. Do not use this setting on Android.
Acquire swapchain image late as possible If enabled, Vulkan delays acquiring the backbuffer until after it renders the frame to an offscreen image. Vulkan uses a staging image to achieve this. Enabling this setting causes an extra blit when presenting the backbuffer. This setting, in combination with double-buffering, can improve performance. However, it also can cause performance issues because the additional blit takes up bandwidth.
Recycle command buffers Indicates whether to recycle or free CommandBuffers after Unity executes them.
Apply display rotation during rendering Enable this to perform all rendering in the native orientation of the display. This has a performance benefit on many devices. For more information, see documentation on Vulkan swapchain pre-rotation.

Identification

Android 平台的 Identification 设置
Android 平台的 Identification 设置
属性 功能
Override Default Package Name Indicates whether to override the default package name for your application.
  Package Name 设置应用程序 ID,用于在设备和 Google Play 应用商店中唯一标识您的应用程序。标识符的基本结构是 com.CompanyName.AppName__,也可以任意选择。iOS 和 Android 共享此设置。| |Version__ 输入捆绑包的构建版本号,用于标识捆绑包的迭代(已发布或未发布)。版本以通用格式指定,该格式包含以点号分隔的数字的字符串(例如,4.3.2)。(在 iOS 和 Android 之间共享。)
Bundle Version Code 内部版本号。此数字仅用于确定一个版本是否比另一个版本更新,数字更大表示版本越新。这不是向用户显示的版本号;向用户显示的版本号由 versionName 属性设置。该值必须设置为整数,例如“100”。您可以根据需要定义,只要每个后续版本具有更高的数字即可。

例如,它可以是构建版本号。或者,可以通过在低 16 位和高 16 位分别编码“x”和“y”将“x.y”格式的版本号转换为整数。或者,每次发布新版本时,只需将数字加一。

如果启用了 Split APKs by target architecture__,请将此数字保持在 100000 以下。每个 APK 必须具有唯一的版本代码,因此 Unity 为 ARMv7 添加 100000,为 ARM64 添加 200000。| |Minimum API Level|运行应用程序所需的最低 Android 版本(API 级别)。| |Target API Level__
编译应用程序针对的目标 Android 版本(API 级别)。

Configuration

Android 平台的 Configuration 设置
Android 平台的 Configuration 设置
Property Description
Scripting Backend Choose the scripting backend you want to use. The scripting backend determines how Unity compiles and executes C# code in your Project.
Mono Compiles C# code into .NET Common Intermediate Language (CIL) and executes that CIL using a Common Language Runtime. See the Mono Project website for more information.
IL2CPP Compiles C# code into CIL, converts the CIL to C++ and then compiles that C++ into native machine code, which executes directly at run time. See IL2CPP for more information.
API Compatibility Level Choose which .NET APIs you can use in your project. This setting can affect compatibility with 3rd-party libraries.
Tip: If you are having problems with a third-party assembly, you can try the suggestion in the API Compatibility Level section below.
.Net 2.0 .Net 2.0 libraries. Maximum .net compatibility, biggest file sizes. Part of the deprecated .NET 3.5 runtime.
.Net 2.0 Subset Subset of full .net compatibility, smaller file sizes. Part of the deprecated .NET 3.5 runtime.
.Net Standard 2.0 Compatible with .NET Standard 2.0. Produces smaller builds and has full cross-platform support.
.Net 4.x Compatible with the .NET Framework 4 (which includes everything in the .NET Standard 2.0 profile as well as additional APIs). Choose this option when using libraries that access APIs not included in .NET Standard 2.0. Produces larger builds and any additional APIs available are not necessarily supported on all platforms. See Referencing additional class library assemblies for more information.
C++ Compiler Configuration Choose the C++ compiler configuration used when compiling IL2CPP generated code.
Note: This property is disabled unless Scripting Backend is set to IL2CPP.
Use incremental GC Enable this to use the incremental garbage collector, which spreads garbage collection over several frames to reduce gc-related spikes in frame duration.
Assembly Version Validation Indicates whether Mono validates types from a strongly-named assembly.
Mute Other Audio Sources Enable this option if you want your Unity application to stop Audio from applications running in the background. Otherwise, Audio from background applications continues to play alongside your Unity application.
Target Architectures Select which CPUs you want to allow the application to run on (32-bit ARM, 64-bit ARM, 32-bit x86, and 64-bit x86–64).
Note: Running Android apps in a 64-bit environment has performance benefits and 64-bit apps can address more than 4 GB of memory space.
Split APKs by target architecture (Experimental) Enable this option to create a separate APK for each CPU architecture selected in Target Architectures. This makes download size smaller for Google Play Store users. This is primarily a Google Play store feature and may not work in other stores. For more details, refer to Multiple APK Support.
Target Devices Specifies the target devices on which the APK is allowed to run.
All Devices The APK is allowed to run on all Android and Chrome OS devices.
Phones and Tablets Only The APK is allowed to run on Android phones and tablets, but not on Chrome OS devices.
Chrome OS Devices Only The APK is allowed to run on Chrome OS devices, but not on Android phones or tablets.
Install Location Specifies application install location on the device (for detailed information, refer to Android Developer documentation on install locations.
Automatic Let the operating system decide. User will be able to move the app back and forth.
Prefer External Install the application to external storage (SD card) if possible. The operating system doesn’t guarantee it; if not possible, the app will be installed to internal memory.
Force Internal Force the application to be installed to internal memory. The user will be unable to move the app to external storage.
Internet Access Choose whether to always add the networking (INTERNET) permission to the Android manifest, even if you are not using any networking APIs. Set to Require by default for development builds.
Auto Only add the internet access permission if you are using a networking API.
Require Always add the internet access permission.
Write Permission Choose whether to enable write access to the external storage (such as the SD card) and add a corresponding permission to the Android manifest. Set to External(SDCard) by default for development builds.
Internal Only grant write permission to internal storage.
External(SDCard) Enable write permission to external storage.
Filter Touches When Obscured Enable this option to discard touches received when another visible window is covering the Unity application. This is to prevent tapjacking.
Sustained Performance Mode Enable this option to set a predictable and consistent level of device performance over longer periods of time, without thermal throttling. Overall performance might be lower when this setting is enabled. Based on the Android Sustained Performance API.
Maximum Java Heap Size Set the maximum Java heap size to user for building (in megabytes). Defaults to 4096.
Low Accuracy Location Enable this option to use low accuracy values with Android location APIs instead.
Chrome OS Input Emulation Chrome OS’s default behaviour is to convert mouse and touchpad input events into touchscreen input events. Un-check this setting to disable the default behavior.
Android TV Compatibility Enable this option to mark the application as Android TV compatible.
  Android Game Enable this option to mark the output package (APK) as a game rather than a regular application.
  Android Gamepad Support Level Choose the level of support your application offers for a gamepad. The options are Works with D-Pad, Supports Gamepad, and Requires Gamepad.
Warn about App Bundle size Enable this option to receive a warning when the size of the Android App Bundle exceeds a certain threshold. This option is selected by default and you can only configure it if you enable the Build App Bundle (Google Play) option in the Build settings.
  App Bundle size threshold Enter a size in Mb. When your App Bundle exceeds this size, Unity will display a warning.
Active Input Handling Choose how you want to handle input from users.
Input Manager (old) Use the default Input window.
Input System (Preview) Use the newer Input system. The Input System is provided as a preview package for this release. To try a preview of the Input System, install the InputSystem package.
Both Use both systems side by side.

API Compatibility Level

可为所有目标选择 mono API 兼容性级别。有时,第三方 .NET 库会使用 .NET 兼容性级别之外的功能。为了解在这种情况下可能发生的问题以及如何以最佳方案修复问题,请尝试以下解决方案:

1.安装适用于 Windows 的 Reflector。 2.将出现问题的相关 API 兼容性级别的 .NET 程序集拖到 Reflector 中。这些程序集位于 Frameworks/Mono/lib/mono/YOURSUBSET/ 下。 3.拖入第三方程序集。 4.右键单击第三方程序集并选择 Analyze。 5.在分析报告中,检查 Depends on 部分。此报告以红色突出显示第三方程序集所依赖的但在您选择的 .NET 兼容性级别中不可用的任何内容。

Script Compilation

Android 平台的脚本编译设置
Android 平台的脚本编译设置
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

Android 平台的 Optimization 设置
Android 平台的 Optimization 设置
Property Description
Prebake Collision Meshes Enable this option to add collision data to Meshes at build time.
Keep Loaded Shaders Alive When enabled, you cannot unload a shader. See Shader Loading for more information.
Preloaded Assets Set an array of Assets for the player to load on startup.
To add new Assets, increase the value of the Size property, then set a reference to the Asset to load in the new Element box that appears.
AOT compilation options Additional options for Ahead of Time (AOT) compilation. This helps optimize the size of the built iOS player.
Strip Engine Code Enable this option if you want the Unity Linker tool to remove code for Unity Engine features that your Project doesn’t use. This setting is only available with the IL2CPP scripting backend.

Most apps don’t use every available DLL. This option strips out DLLs that your app doesn’t use to reduce the size of the built Player. If your app is using one or more classes that would normally be stripped out under your current settings, Unity displays a debug message when you try to build the app.
Managed Stripping Level Choose how Unity strips unused managed (C#) code.The options are Disabled Low, Medium, and High.

When Unity builds your app, the Unity Linker process can strip unused code from the managed DLLs your Project uses. Stripping code can make the resulting executable significantly smaller, but can sometimes accidentally remove code that is in use. For more information about these options, see documentation on Managed code stripping.

For information about bytecode stripping with IL2CPP, see documentation on Managed bytecode stripping with IL2CPP.
Enable Internal profiler (Deprecated) Enable this option to get the profiler data from your device in the Android SDK’s adblogcat output while testing your projects. This is only available in development builds.
Vertex Compression Choose the channel that you want to set for compressing meshes under the vertex compression method, which by default, is set to Mixed. This affects all the meshes in your project. Typically, Vertex Compression is used to reduce the size of mesh data in memory, reduce file size, and improve GPU performance. For information on how to configure vertex compression and limitations of this setting, see [compressing meshes].
Optimize Mesh Data Selecting this option enables stripping of unused vertex attributes from the mesh used in a build.
This reduces the amount of data in the mesh, which might help reduce build size, loading times, and runtime memory usage. However, you must remember to not change material or shader settings at runtime, if you have this setting enabled. See PlayerSettings.stripUnusedMeshComponents for more information.
Texture MipMap Stripping Enable this option to enable mipmap stripping for all platforms, which strips unused mipmaps from Textures at build time. Unity determines unused mipmaps by comparing the value of the mipmap against the Quality Settings for the current platform. If a mipmap value is excluded from every Quality Setting for the current platform, then Unity strips those mipmaps from the build at build time. If QualitySettings.masterTextureLimit is set to a mipmap value that has been stripped, Unity will set the value to the closest mipmap value that has not been stripped.

Logging

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

Android 平台的 Logging 设置
Android 平台的 Logging 设置

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

Legacy

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

Android 平台的 Legacy 设置
Android 平台的 Legacy 设置

Publishing Settings

使用 Publishing Settings 可配置 Unity 构建 Android 应用程序的方式。 若要打开 Publishing Settings,请转到 Edit > Project Settings,选择 Player,选择 Android 图标,然后打开 Publishing Settings 面板。

此部分介绍 Publishing Settings 面板的不同部分及其功能。这些资源包括:

Project Keystore
Project Key
Build
Minify
Split Application Binary

Android 发布面板
Android 发布面板

注意:出于安全原因,Unity 不会保存密钥库或项目密钥密码。

使用 Keystore Manager 窗口可创建、配置和加载密钥和密钥库。 可以从 Keystore Manager 或主 Android 发布面板加载现有密钥库和密钥。如果选择从 Keystore Manager 内部加载这些内容,则 Unity 会自动填充 Project Keystore 和 Project Key 字段。 有关更多信息,请参阅 Keystore Manager 的相关文档。

Project Keystore

密钥库是用于保存签名密钥来实现应用程序安全性的容器。有关详细信息,请参阅 Android 开发者文档:Android 密钥库系统

使用 Project Keystore 设置可选择用于打开的项目的密钥库。加载密钥库时,Unity 会加载该密钥库中的所有密钥。 若要在打开的项目中加载和使用现有密钥库,请执行以下操作:

1.启用 Custom Keystore。 2.打开 Select 下拉列表,选择 Browse,然后从文件系统中选择密钥库。 3.输入您的密钥库密码

如果没有现有密钥库,请将 Custom Keystore 保留为禁用状态。

Unity 使用调试密钥库对应用程序进行签名。 调试密钥库是一种工作密钥库。通过它可以对应用程序进行签名并在本地进行测试。但是,应用商店会拒绝以这种方式签名的应用程序。这是因为应用商店无法使用调试密钥库验证应用程序的有效性和所有权。

属性 描述
Custom Keystore 启用 Custom Keystore 可加载和使用现有密钥库。
Select 启用了 Custom Keystore 时,使用此设置可选择要使用的密钥库。Select 下拉列表中的分区下的密钥库存储在预定义专用位置中。有关更多详细信息,请参阅选择密钥库位置
路径 无需输入密钥库路径。Unity 会基于所选择的密钥库提供此路径。
Password 输入密钥库密码以加载所选的密钥库。

Project Key

加载密钥库时,Unity 会加载该密钥库中的所有密钥。使用 Project Key 设置可从该密钥库中选择一个密钥以用作打开的项目的活动密钥。

属性 描述
Alias 选择要用于打开的项目的密钥。
Password 输入密钥密码。

Build

默认情况下,Unity 使用随 Unity 安装提供的 Android 清单、Gradle 模板和 Proguard 文件构建应用程序。使用 Android Publishing Settings 的 Build 部分可更改这些内容。

若要使用自定义 Android 清单、Gradle 模板或 Proguard 文件,请执行以下操作:

1.启用相应的复选框。Unity 会在项目中创建一个默认文件,文件位置会出现在复选框下方。 2.打开新文件并进行更改。 3.保存对此文件的更改。Unity 下次构建应用程序时会自动使用保存到此文件的更改。

Build 部分中的设置仅适用于当前项目的构建过程。

属性 描述
Custom Main Manifest Android LibraryManifest.xml 文件的可自定义版本。此文件包含有关 Android 应用程序的重要元数据。有关主/库清单的职责的更多信息,请参阅 Android 清单的相关文档。
Custom Launcher Manifest Android LauncherManifest.xml 文件的可自定义版本。此文件包含有关 Android 应用程序启动器的重要元数据。有关启动器清单的职责的更多信息,请参阅 Android 清单的相关文档。
Custom Main Gradle Template mainTemplate.gradle 文件的可自定义版本。此文件包含有关如何将 Android 应用程序构建为库的信息。有关更多信息,请参阅提供自定义 Gradle 模板的相关文档。
Custom Launcher Gradle Template launcherTemplate.gradle_ 文件的可自定义版本。此文件包含有关如何构建 Android 应用程序的说明。有关更多信息,请参阅 build.gradle 模板的相关文档。
Custom Base Gradle Template baseProjectTemplate.gradle 文件的可自定义版本。此文件包含在所有其他模板与 Gradle 项目之间共享的配置。有关更多信息,请参阅 build.gradle 模板的相关文档。
Custom Gradle Properties Template gradle.properties 文件的可自定义版本。此文件包含 Gradle 构建环境的配置设置。这包括:
- JVM(Java 虚拟机)内存配置。
- 允许 Gradle 使用多个 JVM 进行构建的属性。
- 用于选择工具进行缩小的属性。
- 用于在构建应用程序包时不压缩原生库的属性。
Custom Proguard File proguard.txt 文件的可自定义版本。此文件包含缩小过程的配置设置。如果缩小会移除一些应该保留的 Java 代码,则应添加规则以将该代码保留在此文件中。有关更多信息,请参阅缩小的相关文档。

Minify

缩小是一种缩减、混淆和优化应用程序代码的过程。它可以减小代码大小并使代码更难以反汇编。使用 Minify 设置可定义 Unity 应何时以及如何将缩小应用于构建。

在大多数情况下,仅将缩小应用于发布构建(而不是调试构建)是一种很好的做法。这是因为缩小需要时间,可能会使构建速度变慢。由于代码经过优化,它还会使调试更加复杂。

Minify 部分中的设置仅适用于当前项目的构建过程。

属性 描述
Use R8 默认情况下,Unity 使用 Proguard 进行缩小。启用此复选框可改为使用 R8。
Release 如果希望 Unity 在发布构建中缩小应用程序的代码,请启用此复选框。
Debug 如果希望 Unity 在调试构建中缩小应用程序的代码,请启用此复选框。

Split Application Binary

启用 Split Application Binary 选项可将输出包拆分为主包 (APK) 和扩展包 (OBB) 包。如果要发布大于 100 MB 的应用程序,则 Google Play 应用商店需要此功能。

XR Settings

注意:对 XR SDK 的内置支持已被弃用,在 Unity 的未来版本中将不再使用。请改用 Unity XR 插件系统。有关更多信息,请参阅 XR 插件架构

Android Player 的 XR Settings
Android Player 的 XR Settings
设置 功能
Virtual Reality Supported 如果您的应用程序是虚拟现实应用程序,请启用此选项,然后将所需的 VR SDK 添加到列表中。
Virtual Reality SDKs 在列表中添加和删除虚拟现实 SDK。此列表仅在启用 Virtual Reality Supported 时可用。
要将 SDK 添加到列表中,请单击加号 (+) 按钮。
要从列表中删除 SDK,请选择它,然后单击减号 (-) 按钮。
某些 SDK 提供了额外设置,这些设置显示在此处。有关详细信息,请参阅 XR SDK
Stereo Rendering Mode 选择要为虚拟现实设备渲染的方式。
Multi Pass 这是正常的渲染模式。Unity 渲染场景两次:首先渲染左眼图像;然后再次为右眼图像。
Single Pass Multiview or Instanced (Preview) 将两个眼睛图像同时渲染到一个打包的渲染纹理中。这意味着整个场景只渲染一次,这大大减少了 CPU 处理时间。



  • 5.5 版中的更新功能
  • 在 2017.3 版中添加了 Sustained Performance Mode 属性
  • 在 2018.1 版中添加了 .NET 4.x 运行时
  • 在 2018.2 版中添加了 Android Multiple APK 功能
  • 2019.1 中为 Android 添加了 OpenGL ES 3.2 支持 NewIn20191
  • 在 Unity 2019.1 中添加了输入系统预览
  • 在 Unity 2019.1 中添加了 Render outside safe area
  • 在 Unity 2019.2 中添加了 Warn about App Bundle size 选项
  • 在 Unity 2019.3 将 GPU Skinning 重命名为 Compute Skinning
  • 在 Unity 2019.3 中删除了 Vuforia
  • 在 Unity 2019.3 中已弃用对内置 XR SDK 的支持。NewIn20193
  • Updated for Texture compression format
Android 环境设置
Android 密钥库管理器