Version: 2017.1
通用 Windows 平台:C# 脚本中的 WinRT API
脚本后端

通用 Windows 平台播放器设置 (Universal Windows Platform Player Settings)

This page details the Player Settings specific to Universal Windows Platform. A description of the general Player Settings can be found here.

Most of these settings are transferred to Package.appxmanifest when creating Visual Studio solution for the first time.

Note: If you build your project on top of the existing one, Unity won’t overwrite Package.appxmanifest file if it’s already present, that means if you change something in Player Settings be sure to check Package.appxmanifest, if you want Package.appxmanifest to be regenerated, simply delete it, and rebuild your project from Unity.

To read more about App package manifest, please visit http://msdn.microsoft.com/en-us/library/windows/apps/br211474.aspx.

Settings from Packaging, Application UI, Tile, Splash screen, Capabilities directly transfer to settings in Package.appxmanifest file.

Player Settings 中支持的方向 (Supported orientations) 也会填充到清单(Visual Studio 解决方案中的 Package.appxmanifest 文件)。在通用 Windows 应用程序上,Unity 会将方向重置为您在 Player Settings 中使用的方向,无论在清单中指定了什么设置均是如此。这是因为 Windows 本身将忽略台式机和平板电脑上的这些设置。请注意,始终可使用 Unity Scripting API 来更改支持的方向。

Certificate

每个通用 Windows 应用程序都需要一个标识开发者的证书,如果您未提供自己的证书,Unity 将创建默认证书。

Compilation

如您所知,Unity 在编译脚本文件时使用 Mono,而您可以使用 .NET 3.5 中的 API。Compilation Overrides 允许在 C# 文件中使用适用于通用 Windows 平台的 .NET(也称为 .NET Core),此处提供了 API。

当 Compilation Overrides 设置为:

  • None - 使用 Mono 编译器编译 C# 文件。
  • Use .Net Core - 使用 Microsoft 编译器和 .NET Core 编译 C# 文件,您可以使用 Windows 运行时 API,但无法通过 JS 语言访问在 C# 文件中实现的类。注意:使用来自 Windows 运行时的 API 时,建议使用 ENABLE_WINMD_SUPPORT 定义来包装代码,因为该 API 仅在构建到通用 Windows 平台时可用,在 Unity Editor 中不可用。
  • Use .Net Core Partially - 使用 Microsoft 编译器和 .NET Core 编译不在 Plugins、Standard Assets、Pro Standard Assets 文件夹中的 C# 文件,而使用 Mono 编译器编译所有其他 C# 文件。优点是可通过 JS 语言访问 C# 中实现的类。 注意:您将无法在 Unity Editor 中测试 .NET Core API,因为它无法访问 .NET Core,所以您只能在运行通用 Windows 应用程序时测试该 API。

注意:不能在 JS 脚本中使用 .NET Core API。

Here’s a simple example how to use .NET Core API in scripts.

string GetTemporaryFolder()
{
# if ENABLE_WINMD_SUPPORT
    return Windows.Storage.ApplicationData.Current.TemporaryFolder.Path;
# else
    return "LocalFolder";
# endif
}

Misc

Unprocessed Plugins contains a list of plugins which are ignored by Unity’s preprocessing tools (like SerializationWeaver, AssemblyPreprocessor, rrw), usually you don’t need to modify this list, unless you’re getting an error that Unity’s failed to preprocess your plugin.

What will happen if you’ll add a plugin to this list?

Unity won’t inject additional IL code into your assembly used for serialization purposes, but if you’re plugin isn’t referencing UnityEngine.dll, that’s totally fine, because Unity won’t serialize any data from your plugin.

Independent Input Source

Let’s you enable an option for independent input source, you can read more here. Basically this makes your input more responsive, and usually you want this option to be enabled.

Low Latency Presentation API Let’s you enable Low Latency Presentation API, basically this create D3D11 swapchain with DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT flag, read more here and should increase input responsiveness. This option is disabled by default because on hardware with older GPU drivers, this option makes game laggy, if you enable this option - be sure to profile your game if the performance is still acceptable.

Capabilities

这些选项直接复制到 Package.appxmanifest。

Note: If you’re build your game on top of previous package, Package.appxmanifest won’t be overwritten.


• 2017–05–16 页面已修订但未经编辑审查

通用 Windows 平台:C# 脚本中的 WinRT API
脚本后端