Organização do projeto

Introdução

Uma vez que Godot não tem nenhuma restrição na estrutura do projeto ou uso do sistema de arquivos, organizar arquivos enquanto aprendendo a engine pode parecer desafiador. This tutorial suggests a workflow which should be a good starting point. We will also cover using version control with Godot.

Organização

Godot is scene-based in nature, and uses the filesystem as-is, without metadata or an asset database.

Unlike other engines, many resources are contained within the scene itself, so the amount of files in the filesystem is considerably lower.

Considering that, the most common approach is to group assets as close to scenes as possible; when a project grows, it makes it more maintainable.

As an example, one can usually place into a single folder their basic assets, such as sprite images, 3D model meshes, materials, and music, etc. They can then use a separate folder to store built levels that use them.

/project.godot
/docs/.gdignore  # See "Ignoring specific folders" below
/docs/learning.html
/models/town/house/house.dae
/models/town/house/window.png
/models/town/house/door.png
/characters/player/cubio.dae
/characters/player/cubio.png
/characters/enemies/goblin/goblin.dae
/characters/enemies/goblin/goblin.png
/characters/npcs/suzanne/suzanne.dae
/characters/npcs/suzanne/suzanne.png
/levels/riverdale/riverdale.scn

Importando

Godot versions prior to 3.0 did the import process from files outside the project. While this can be useful in large projects, it resulted in an organization hassle for most developers.

Because of this, assets are now transparently imported from within the project folder.

Ignoring specific folders

Para evitar que Godot importe arquivos contidos em uma pasta específica, crie um arquivo vazio chamado .gdignore na pasta (o início . é necessário). Isso pode ser útil para acelerar a importação inicial do projeto.

Nota

Para criar um arquivo cujo nome começa com um ponto no Windows, você pode usar um editor de texto como Notepad++ ou usar o seguinte comando em um prompt de comando: type nul > .gdignore

Uma vez que a pasta é ignorada, os recursos dessa pasta não podem mais ser carregados usando os métodos load() e preload().

Ignorar uma pasta também irá escondê-la automaticamente do dock FileSystem, que pode ser útil para reduzir a desordem.

Case sensitivity

Windows and recent macOS versions use case-insensitive filesystems by default, whereas Linux distributions use a case-sensitive filesystem by default. This can cause issues after exporting a project, since Godot’s PCK virtual filesystem is case-sensitive. To avoid this, it’s recommended to stick to snake_case naming for all files in the project (and lowercase characters in general).

Nota

You can break this rule when style guides say otherwise (such as the C# style guide). Still, be consistent to avoid mistakes.

On Windows 10, to further avoid mistakes related to case sensitivity, you can also make the project folder case-sensitive. After enabling the Windows Subsystem for Linux feature, run the following command in a PowerShell window:

# To enable case-sensitivity:
fsutil file setcasesensitiveinfo <path to project folder> enable

# To disable case-sensitivity:
fsutil file setcasesensitiveinfo <path to project folder> disable

If you haven’t enabled the Windows Subsystem for Linux, you can enter the following line in a PowerShell window running as Administrator then reboot when asked:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux