exporting_projects.rst 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. .. _doc_exporting_projects:
  2. Exporting projects
  3. ==================
  4. .. highlight:: none
  5. Why export?
  6. -----------
  7. Originally, Godot did not have any means to export projects. The
  8. developers would compile the proper binaries and build the packages for
  9. each platform manually.
  10. When more developers (and even non-programmers) started using it, and
  11. when our company started taking more projects at the same time, it
  12. became evident that this was a bottleneck.
  13. On PC
  14. ~~~~~
  15. Distributing a game project on PC with Godot is rather easy. Drop
  16. the Godot binary in the same directory as the ``project.godot`` file,
  17. then compress the project directory and you are done.
  18. It sounds simple, but there are probably a few reasons why the developer
  19. may not want to do this. The first one is that it may not be desirable
  20. to distribute loads of files. Some developers may not like curious users
  21. peeking at how the game was made, others may find it inelegant, and so on.
  22. Another reason is that the developer might prefer a specially-compiled
  23. binary, which is smaller in size, more optimized and does not include
  24. tools like the editor and debugger.
  25. Finally, Godot has a simple but efficient system for
  26. :ref:`creating DLCs as extra package files <doc_exporting_pcks>`.
  27. .. warning::
  28. Godot does not support loading PCK files larger than 2 GB yet. If your
  29. exported project data is larger than 2 GB, you will need to split it into
  30. several PCK files by :ref:`exporting additional PCKs <doc_exporting_pcks>`
  31. and loading them at run-time.
  32. On mobile
  33. ~~~~~~~~~
  34. The same scenario on mobile platforms is a little worse.
  35. To distribute a project on those devices, a binary for each of
  36. those platforms is built, then added to a native project together
  37. with the game data.
  38. This can be troublesome because it means that the developer must be
  39. familiarized with the SDK of each platform before even being able to
  40. export. While learning each SDK is always encouraged, it can be
  41. frustrating to be forced to do it at an undesired time.
  42. There is also another problem with this approach: different devices
  43. prefer some data in different formats to run. The main example of this
  44. is texture compression. All PC hardware uses S3TC (BC) compression and
  45. that has been standardized for more than a decade, but mobile devices
  46. use different formats for texture compression, such as PVRTC (iOS) or
  47. ETC (Android).
  48. Export menu
  49. -----------
  50. After many attempts at different export workflows, the current one has
  51. proven to work the best. At the time of this writing, not all platforms are
  52. supported yet, but the supported platforms continue to grow.
  53. To open the export menu, click the **Export** button:
  54. .. image:: img/export.png
  55. The export menu will open. However, it will be completely empty.
  56. This is because we need to add an export preset.
  57. .. image:: img/export_dialog.png
  58. To create an export preset, click the **Add…** button at the top
  59. of the export menu. This will open a drop-down list of platforms
  60. to choose from for an export preset.
  61. .. image:: img/export_preset.png
  62. The default options are often enough to export, so tweaking them is
  63. usually not necessary. However, many platforms require additional
  64. tools (SDKs) to be installed to be able to export. Additionally, Godot
  65. needs export templates installed to create packages. The export menu
  66. will complain when something is missing and will not allow the user to
  67. export for that platform until they resolve it:
  68. .. image:: img/export_error.png
  69. At that time, the user is expected to come back to the documentation and follow
  70. instructions on how to properly set up that platform.
  71. Export templates
  72. ~~~~~~~~~~~~~~~~
  73. Apart from setting up the platform, the export templates must be
  74. installed to be able to export projects. They can be obtained as a
  75. TPZ file (which is a renamed ZIP archive) from the
  76. `download page of the website <https://www.godotengine.org/download>`_.
  77. Once downloaded, they can be installed using the **Install Export Templates**
  78. option in the editor:
  79. .. image:: img/exptemp.png
  80. .. _doc_exporting_projects_export_mode:
  81. Export mode
  82. ~~~~~~~~~~~
  83. When exporting, Godot makes a list of all the files to export and then
  84. creates the package. There are 3 different modes for exporting:
  85. - Export all resources in the project
  86. - Export selected scenes (and dependencies)
  87. - Export selected resources (and dependencies)
  88. .. image:: img/expres.png
  89. **Export all resources in the project** will export every resource in the
  90. project. **Export selected scenes** and **Export selected resources** gives
  91. you a list of the scenes or resources in the project, and you have to
  92. select every scene or resource you want to export.
  93. .. image:: img/expselected.png
  94. Exporting from the command line
  95. -------------------------------
  96. In production, it is useful to automate builds, and Godot supports this
  97. with the ``--export`` and ``--export-debug`` command line parameters.
  98. Exporting from the command line still requires an export preset to define
  99. the export parameters. A basic invocation of the command would be:
  100. .. code-block:: shell
  101. godot --export "Windows Desktop" some_name
  102. This will export to ``some_name.exe``, assuming there is a preset
  103. called "Windows Desktop" and the template can be found.
  104. The output path is relative to the project path or absolute;
  105. it does not respect the directory the command was invoked from.
  106. You can also configure it to export only the PCK or ZIP file, allowing
  107. a single export to be used with multiple Godot executables.
  108. This takes place if the target name ends with ``.pck`` or ``.zip``.
  109. It is often useful to combine the ``--export`` flag with the ``--path``
  110. flag, and to create a dedicated export preset for automated export:
  111. .. code-block:: shell
  112. godot --path path/to/project --export "pck" game_name.pck
  113. PCK versus ZIP pack file formats
  114. --------------------------------
  115. Each format has its upsides and downsides. PCK is the default and recommended
  116. format for most use cases, but you may want to use a ZIP archive instead
  117. depending on your needs.
  118. **PCK format:**
  119. - Uncompressed format. Larger file size, but faster to read/write.
  120. - Not readable and writable using tools normally present on the user's
  121. operating system, even though there are
  122. `third-party tools <https://github.com/hhyyrylainen/GodotPckTool>`__
  123. to extract and create PCK files.
  124. **ZIP format:**
  125. - Compressed format. Smaller file size, but slower to read/write.
  126. - Readable and writable using tools normally present on the user's operating system.
  127. This can be useful to make modding easier (see also :ref:`doc_exporting_pcks`).
  128. .. warning::
  129. Due to a `known bug <https://github.com/godotengine/godot/pull/42123>`__,
  130. when using a ZIP file as a pack file, the exported binary will not try to use
  131. it automatically. Therefore, you have to create a *launcher script* that
  132. the player can double-click or run from a terminal to launch the project::
  133. :: launch.bat (Windows)
  134. @echo off
  135. my_project.exe --main-pack my_project.zip
  136. # launch.sh (Linux)
  137. ./my_project.x86_64 --main-pack my_project.zip
  138. Save the launcher script and place it in the same folder as the exported binary.
  139. On Linux, make sure to give executable permissions to the launcher script using
  140. the command ``chmod +x launch.sh``.