project_organization.rst 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. Importing
  37. ---------
  38. Godot versions prior to 3.0 did the import process from files outside
  39. the project. While this can be useful in large projects, it
  40. resulted in an organization hassle for most developers.
  41. Because of this, assets are now transparently imported from within the project
  42. folder.
  43. Ignoring specific folders
  44. ~~~~~~~~~~~~~~~~~~~~~~~~~
  45. To prevent Godot from importing files contained in a specific folder, create
  46. an empty file called ``.gdignore`` in the folder (the leading ``.`` is required).
  47. This can be useful to speed up the initial project importing.
  48. .. note::
  49. To create a file whose name starts with a dot on Windows, you can use a
  50. text editor such as Notepad++ or use the following command in a
  51. command prompt: ``type nul > .gdignore``
  52. Once the folder is ignored, resources in that folder can't be loaded anymore
  53. using the ``load()`` and ``preload()`` methods.
  54. Ignoring a folder will also automatically hide it from the FileSystem dock,
  55. which can be useful to reduce clutter.
  56. Case sensitivity
  57. ----------------
  58. Windows and recent macOS versions use case-insensitive filesystems by default,
  59. whereas Linux distributions use a case-sensitive filesystem by default.
  60. This can cause issues after exporting a project, since Godot's PCK virtual
  61. filesystem is case-sensitive. To avoid this, it's recommended to stick to
  62. ``snake_case`` naming for all files in the project (and lowercase characters
  63. in general).
  64. .. note::
  65. You can break this rule when style guides say otherwise (such as the
  66. C# style guide). Still, be consistent to avoid mistakes.
  67. On Windows 10, to further avoid mistakes related to case sensitivity,
  68. you can also make the project folder case-sensitive. After enabling the Windows
  69. Subsystem for Linux feature, run the following command in a PowerShell window::
  70. # To enable case-sensitivity:
  71. fsutil file setcasesensitiveinfo <path to project folder> enable
  72. # To disable case-sensitivity:
  73. fsutil file setcasesensitiveinfo <path to project folder> disable
  74. If you haven't enabled the Windows Subsystem for Linux, you can enter the
  75. following line in a PowerShell window *running as Administrator* then reboot
  76. when asked::
  77. Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux