Tags de funcionalidade
Introdução
Godot tem um sistema especial para marcar a disponibilidade de recursos. Cada recurso é representado como uma string, que pode se referir a muitos dos seguintes:
Nome da plataforma.
Arquitetura da plataforma (64-bits ou 32-bits, x86 ou ARM).
Tipo da plataforma (desktop, celular, Web).
Algoritmos de compressão de textura suportados na plataforma.
Se uma compilação é
debugourelease(depuraçãoinclui o editor).Se o projeto está sendo executado pelo editor ou um binário "standalone".
Muitas outras coisas.
Features can be queried at runtime from the singleton API by calling:
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.
Recursos padrão
Aqui está uma lista da maioria das tags de funcionalidades em Godot. Tenha em mente que elas possuem sensibilidade de caixa:
Etiqueta de características |
Descrição |
|---|---|
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) |
visionos |
Running on visionOS (but not within a Web browser) |
windows |
Executando no Windows |
linuxbsd |
Executando no Linux ou *BSD |
debug |
Executando uma compilação de debug (incluindo o editor) |
release |
Executando em uma compilação de release |
editor |
Executando em uma compilação de editor |
editor_hint |
Running on an editor build, and inside the editor |
editor_runtime |
Running on an editor build, and running the project |
template |
Executando em uma compilação não-editor (modelo de exportação) |
double |
Running on a double-precision build |
single |
Running on a single-precision build |
64 |
Executando em uma compilação de 64-bits (qualquer arquitetura) |
32 |
Executando em uma compilação de 32-bits (qualquer arquitetura) |
x86_64 |
Executando em uma compilação x86 de 64-bits |
x86_32 |
Executando em uma compilação x86 de 32-bits |
x86 |
Running on an x86 build (any bitness) |
arm64 |
Executando uma compilação ARM de 64-bits |
arm32 |
Executando uma compilação ARM de 32-bits |
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 |
SO hospedeiro é uma plataforma móvel |
pc |
SO hospedeiro é uma plataforma de PC (desktop/laptop) |
web |
SO hospedeiro é um navegador da Web |
nothreads |
Running without threading support |
threads |
Running with threading support |
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 |
Texturas usando compactação ETC1 são suportadas |
etc2 |
Texturas usando compactação ETC2 são suportadas |
s3tc |
Texturas usando compactação S3TC (DXT/BC) são suportadas |
movie |
Movie Maker mode is active |
shader_baker |
Project was exported with shader baking enabled (only applies to the exported project, not when running in the editor) |
dedicated_server |
Project was exported as a dedicated server (only applies to the exported project, not when running in the editor) |
Aviso
With the exception of texture compression, web_<platform> and
movie feature tags, default feature tags are immutable.
This means that they will not change depending on runtime conditions.
For example, OS.has_feature("mobile") will return false
when running a project exported to Web on a mobile device.
To check whether a project exported to Web is running on a mobile device,
use OS.has_feature("web_android") or OS.has_feature("web_ios").
Funções personalizadas
É possível adicionar funções personalizados a uma compilação; usar o campo relevante no conjunto prévio de exportação usado para gerá-lo:
Nota
Custom feature tags are only used when running the exported project (including with Implantação com um clique). They are not used when running the project from the editor, even if the export preset marked as Runnable for your current platform has custom feature tags defined.
Custom feature tags are also not used in EditorExportPlugin scripts. Instead, feature tags in EditorExportPlugin will reflect the device the editor is currently running on.
Substituindo configurações do projeto
Funções podem ser usados para substituir valores específicos de configuração nas Configurações de Projeto. Isso permite que você personalize melhor qualquer configuração ao fazer uma compilação.
No exemplo a seguir, um ícone diferente é adicionado para a construção demo do jogo (que foi personalizado em um conjunto prévio especial de exportação, que, por sua vez, inclui apenas níveis para demonstração).
The desired configuration is selected, which effectively copies its properties to the panel above (1). The "demo_build" feature tag is selected (2). The configuration is added to the project settings (3).
After overriding, a new field is added for this specific configuration.
Nota
Ao usar a funcionalidade project settings "override.cfg" functionality (que não está relacionada às tags de recursos), lembre-se de que as tags de recursos ainda se aplicam. Portanto, certifique-se de também substituir a configuração com a(s) tag(s) de recurso desejada(s) se quiser que elas substituam as configurações base do projeto em todas as plataformas e configurações.
Substituições padrão
Já existem muitas configurações que vêm com substituições por padrão; eles podem ser encontrados em muitas seções das configurações do projeto.
Taking feature tags into account when reading project settings
By default, feature tags are not taken into account when reading project settings using the typical approaches (ProjectSettings.get_setting or ProjectSettings.get). Instead, you must use ProjectSettings.get_setting_with_override.
For example, with the following project settings:
[section]
subsection/example = "Release"
subsection/example.debug = "Debug"
Using ProjectSettings.get_setting("section/subsection/example") will return
"Release" regardless of whether a debug build is currently running. On the
other hand, ProjectSettings.get_setting_with_override("section/subsection/example")
will obey feature tags and will return "Debug" if using a debug build.
Personalizando a compilação
As tags de funcionalidade também podem ser usadas para personalizar um processo de compilação, escrevendo um ExportPlugin personalizado. Elas também são usados para especificar qual biblioteca compartilhada é carregada e exportada em GDExtension.