Up to date
This page is up to date for Godot 4.2
.
If you still find outdated information, please open an issue.
プロジェクトの構成¶
はじめに¶
Godotにはプロジェクト構造やファイルシステムの使用方法に制限がないため、エンジンを学習する際にファイルを整理することが難しいようです。このチュートリアルでは、出発点として適切なワークフローを提案します。また、Godotでのバージョン管理の使用についても説明します。
構成¶
Godotは本質的にシーンベースであり、メタデータやアセットデータベースなしで、ファイルシステムをそのまま使用します。
他のエンジンとは異なり、多くのリソースはシーン自体に含まれているため、ファイルシステム内のファイルの量はかなり少なくなります。
それを考慮すると、最も一般的なアプローチは、可能な限りシーンに近いアセットをグループ化することです。そうしておけば、プロジェクトが大きくなった時の保守性が高まります。
例として、通常は、スプライト画像、3Dモデルメッシュ、マテリアル、音楽などの基本的なアセットを単一のフォルダに配置できます。その後、別のフォルダを使用して、それらを使用してビルドされたレベルを格納することもできます。
/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
Style guide¶
For consistency across projects, we recommend following these guidelines:
Use snake_case for folder and file names (with the exception of C# scripts). This sidesteps case sensitivity issues that can crop up after exporting a project on Windows. C# scripts are an exception to this rule, as the convention is to name them after the class name which should be in PascalCase.
Use PascalCase for node names, as this matches built-in node casing.
In general, keep third-party resources in a top-level
addons/
folder, even if they aren't editor plugins. This makes it easier to track which files are third-party. There are some exceptions to this rule; for instance, if you use third-party game assets for a character, it makes more sense to include them within the same folder as the character scenes and scripts.
インポート¶
バージョン3.0以前のGodotは、プロジェクト外部のファイルからインポートプロセスを実行しました。これは大規模なプロジェクトでは便利ですが、ほとんどの開発者にとって構成に手間がかかります。
このため、アセットはプロジェクトフォルダ内から透過的にインポートされるようになりました。
特定のフォルダを無視する¶
Godot が特定のフォルダに含まれるファイルをインポートしないようにするには、フォルダ内に .gdignore
という空のファイルを作成します (先頭に .
が必要です)。これは、(既存の構成などからの)初期プロジェクトのインポートを高速化するのに役立ちます。
注釈
To create a file whose name starts with a dot on Windows, place a dot at both the beginning and end of the filename (".gdignore."). Windows will automatically remove the trailing dot when you confirm the name.
Alternatively, you can use a text editor such as Notepad++ or use the
following command in a command prompt: type nul > .gdignore
Once the folder is ignored, resources in that folder can't be loaded anymore
using the load()
and preload()
methods. Ignoring a folder will also
automatically hide it from the FileSystem dock, which can be useful to reduce clutter.
Note that the .gdignore
file's contents are ignored, which is why the file
should be empty. It does not support patterns like .gitignore
files do.
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).
注釈
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