project_organization.rst 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. .. _doc_project_organization:
  2. Project organization
  3. ====================
  4. Introduction
  5. ------------
  6. Since Godot has no restrictions on project structure or filesystem usage,
  7. organizing files when learning the engine can seem challenging. This
  8. tutorial suggests a workflow which should be a good starting point.
  9. We will also cover using version control with Godot.
  10. Organization
  11. ------------
  12. Godot is scene-based in nature, and uses the filesystem as-is,
  13. without metadata or an asset database.
  14. Unlike other engines, many resources are contained within the scene
  15. itself, so the amount of files in the filesystem is considerably lower.
  16. Considering that, the most common approach is to group assets as close
  17. to scenes as possible; when a project grows, it makes it more
  18. maintainable.
  19. As an example, one can usually place into a single folder their basic assets,
  20. such as sprite images, 3D model meshes, materials, and music, etc.
  21. They can then use a separate folder to store built levels that use them.
  22. .. code-block:: none
  23. /project.godot
  24. /docs/.gdignore # See "Ignoring specific folders" below
  25. /docs/learning.html
  26. /models/town/house/house.dae
  27. /models/town/house/window.png
  28. /models/town/house/door.png
  29. /characters/player/cubio.dae
  30. /characters/player/cubio.png
  31. /characters/enemies/goblin/goblin.dae
  32. /characters/enemies/goblin/goblin.png
  33. /characters/npcs/suzanne/suzanne.dae
  34. /characters/npcs/suzanne/suzanne.png
  35. /levels/riverdale/riverdale.scn
  36. Style guide
  37. -----------
  38. For consistency across projects, we recommend following these guidelines:
  39. - Use **snake_case** for folder and file names (with the exception of C#
  40. scripts). This sidesteps case sensitivity issues that can crop up after
  41. exporting a project on Windows. C# scripts are an exception to this rule,
  42. as the convention is to name them after the class name which should be
  43. in PascalCase.
  44. - Use **PascalCase** for node names, as this matches built-in node casing.
  45. - In general, keep third-party resources in a top-level ``addons/`` folder, even
  46. if they aren't editor plugins. This makes it easier to track which files are
  47. third-party. There are some exceptions to this rule; for instance, if you use
  48. third-party game assets for a character, it makes more sense to include them
  49. within the same folder as the character scenes and scripts.
  50. Importing
  51. ---------
  52. Godot versions prior to 3.0 did the import process from files outside
  53. the project. While this can be useful in large projects, it
  54. resulted in an organization hassle for most developers.
  55. Because of this, assets are now transparently imported from within the project
  56. folder.
  57. Ignoring specific folders
  58. ~~~~~~~~~~~~~~~~~~~~~~~~~
  59. To prevent Godot from importing files contained in a specific folder, create
  60. an empty file called ``.gdignore`` in the folder (the leading ``.`` is required).
  61. This can be useful to speed up the initial project importing.
  62. .. note::
  63. To create a file whose name starts with a dot on Windows, place a dot
  64. at both the beginning and end of the filename (".gdignore."). Windows
  65. will automatically remove the trailing dot when you confirm the name.
  66. Alternatively, you can use a text editor such as Notepad++ or use the
  67. following command in a command prompt: ``type nul > .gdignore``
  68. Once the folder is ignored, resources in that folder can't be loaded anymore
  69. using the ``load()`` and ``preload()`` methods. Ignoring a folder will also
  70. automatically hide it from the FileSystem dock, which can be useful to reduce clutter.
  71. Note that the ``.gdignore`` file's contents are ignored, which is why the file
  72. should be empty. It does not support patterns like ``.gitignore`` files do.
  73. .. _doc_project_organization_case_sensitivity:
  74. Case sensitivity
  75. ----------------
  76. Windows and recent macOS versions use case-insensitive filesystems by default,
  77. whereas Linux distributions use a case-sensitive filesystem by default.
  78. This can cause issues after exporting a project, since Godot's PCK virtual
  79. filesystem is case-sensitive. To avoid this, it's recommended to stick to
  80. ``snake_case`` naming for all files in the project (and lowercase characters
  81. in general).
  82. .. note::
  83. You can break this rule when style guides say otherwise (such as the
  84. C# style guide). Still, be consistent to avoid mistakes.
  85. On Windows 10, to further avoid mistakes related to case sensitivity,
  86. you can also make the project folder case-sensitive. After enabling the Windows
  87. Subsystem for Linux feature, run the following command in a PowerShell window::
  88. # To enable case-sensitivity:
  89. fsutil file setcasesensitiveinfo <path to project folder> enable
  90. # To disable case-sensitivity:
  91. fsutil file setcasesensitiveinfo <path to project folder> disable
  92. If you haven't enabled the Windows Subsystem for Linux, you can enter the
  93. following line in a PowerShell window *running as Administrator* then reboot
  94. when asked::
  95. Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux