Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
功能标签¶
前言¶
Godot 有一个特殊的系统来标记功能的可用性。每个功能均表示为一个字符串,可以引用以下各项:
平台名称。
平台架构(64 位或 32 位,x86 或 ARM)。
平台类型(桌面、移动、Web)。
平台上支持的纹理压缩算法。
构建是
debug
还是release
(debug
包括编辑器)。项目是从编辑器运行还是从“独立”二进制文件运行。
其他更多的东西。
可以在运行时通过调用以下功能从单例 API 查询功能:
OS.has_feature(name)
OS.HasFeature(name);
OS feature tags are used by GDExtension to determine which libraries to load.
For example, a library for linux.debug.editor.x86_64
will be
loaded only on a debug editor build for Linux x86_64.
默认功能¶
这是 Godot 中大多数功能标签的列表。请记住它们区分大小写:
功能标签 |
描述 |
---|---|
android |
Running on Android (but not within a Web browser) |
bsd |
Running on *BSD (but not within a Web browser) |
linux |
Running on Linux (but not within a Web browser) |
macos |
Running on macOS (but not within a Web browser) |
ios |
Running on iOS (but not within a Web browser) |
uwp |
Running on UWP (but not within a Web browser) |
windows |
在 Windows 上运行 |
linuxbsd |
Running on Linux or *BSD |
debug |
在调试版本上运行(包括编辑器) |
release |
在发布版本上运行 |
editor |
在编辑器构建上运行 |
template |
Running on a non-editor (export template) build |
double |
Running on a double-precision build |
single |
Running on a single-precision build |
64 |
在 64 位构建上运行(不限架构) |
32 |
在 32 位构建上运行(不限架构) |
x86_64 |
在 64 位 x86 架构构建上运行 |
x86_32 |
在 32 位 x86 架构构建上运行 |
x86 |
Running on an x86 build (any bitness) |
arm64 |
在 64 位 ARM 架构构建上运行 |
arm32 |
在 32 位 ARM 架构构建上运行 |
arm |
Running on an ARM build (any bitness) |
rv64 |
Running on a 64-bit RISC-V build |
riscv |
Running on a RISC-V build (any bitness) |
ppc64 |
Running on a 64-bit PowerPC build |
ppc32 |
Running on a 32-bit PowerPC build |
ppc |
Running on a PowerPC build (any bitness) |
wasm64 |
Running on a 64-bit WebAssembly build (not yet possible) |
wasm32 |
Running on a 32-bit WebAssembly build |
wasm |
Running on a WebAssembly build (any bitness) |
mobile |
宿主操作系统是移动平台 |
pc |
宿主操作系统是 PC 平台(台式机/笔记本电脑) |
web |
宿主操作系统是网页浏览器 |
web_android |
Host OS is a Web browser running on Android |
web_ios |
Host OS is a Web browser running on iOS |
web_linuxbsd |
Host OS is a Web browser running on Linux or *BSD |
web_macos |
Host OS is a Web browser running on macOS |
web_windows |
Host OS is a Web browser running on Windows |
etc |
支持使用 ETC1 压缩的纹理 |
etc2 |
支持使用 ETC2 压缩的纹理 |
s3tc |
支持使用 S3TC(DXT/BC)压缩的纹理 |
movie |
Movie Maker mode is active |
警告
With the exception of texture compression and movie
feature tags,
default feature tags are immutable. This means that they will not
change depending on run-time conditions. For example,
OS.has_feature("mobile")
will return false
when running a project
exported to HTML5 on a mobile device.
要检查导出为 HTML5 的项目是否是在移动设备上运行,请调用 JavaScript 代码读取浏览器的用户代理。
自定义功能¶
可以向构建添加自定义功能;使用导出预设中用于生成它的相关字段:
![../../_images/feature_tags1.png](../../_images/feature_tags1.png)
备注
自定义特性标签只会在运行导出后的项目中使用(包括 一键部署)。从编辑器中运行项目时不会使用,即便标记为可执行的导出预设对应的平台上存在自定义特性标签。
覆盖项目设置¶
功能可用于覆盖项目设置中的特定配置值。这样可以在构建时更好地定制任意配置。
在下面的示例中,为游戏的演示版本添加了一个不同的图标(在特定的导出预设中进行了自定义,而该预设仅包含演示关卡)。
![../../_images/feature_tags2.png](../../_images/feature_tags2.png)
覆盖后, 将为此特定配置添加一个新字段:
![../../_images/feature_tags3.png](../../_images/feature_tags3.png)
备注
当使用项目设置的“override.cfg”功能时(与功能标签无关),记住功能标签仍然适用。因此,如果你想让它们覆盖所有平台和配置上的基本项目设置,请确保同时用所需的功能标签覆盖设置。
默认覆盖¶
默认情况下, 已有很多覆盖的设置;它们可以在项目设置的许多地方中找到.
![../../_images/feature_tags4.png](../../_images/feature_tags4.png)
自定义构建¶
Feature tags can be used to customize a build process too, by writing a custom ExportPlugin. They are also used to specify which shared library is loaded and exported in GDExtension.