import_process.rst 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. .. _doc_import_process:
  2. Import process
  3. ==============
  4. Importing assets in Godot
  5. -------------------------
  6. To import assets in Godot, place your assets (image files, scenes, audio
  7. files, fonts, etc) directly in the project folder. There are 2 ways to achieve this:
  8. - **For any file type:** Copy files manually with your operating system's file manager.
  9. - **For file types that can be imported by Godot:**
  10. Drag-and-drop files from the operating system's file manager to the editor's FileSystem dock.
  11. This only works with *resource* file types (i.e. file types that Godot can import).
  12. Godot will automatically import these files internally and keep the imported
  13. resources hidden in a ``res://.godot/imported/`` folder.
  14. This means that when trying to access imported assets through code, you
  15. need to use the :ref:`Resource Loader<class_ResourceLoader>` as it will
  16. automatically take into account where the internal files are saved. If you
  17. try and access an imported asset using the :ref:`FileAccess <class_FileAccess>` class,
  18. it will work in the editor, but **it will break in the exported project**.
  19. However, the :ref:`Resource Loader<class_ResourceLoader>` cannot access
  20. non-imported files. Only the :ref:`FileAccess <class_FileAccess>` class can.
  21. Changing import parameters
  22. --------------------------
  23. .. note::
  24. Import parameters are only present in *non-native* Godot resource types.
  25. This means Godot's own scene and resource file formats (``.tscn``, ``.scn``,
  26. ``.tres``, ``.res``) don't have import options you can select in the Import
  27. dock.
  28. To change the import parameters of an asset in Godot, select the relevant
  29. resource in the FileSystem dock:
  30. .. image:: img/import_process_example.webp
  31. After adjusting the parameters, click **Reimport**. Be careful: if you select
  32. another file in the FileSystem dock before clicking **Reimport**, changes will
  33. be discarded. After clicking **Reimport**, the chosen parameters will only be
  34. used for this asset and on future reimports.
  35. Changing the import parameters of several assets at the same time is also
  36. possible. Simply select all of them together in the resources dock and the
  37. exposed parameters will apply to all of them when reimporting.
  38. Reimporting multiple assets
  39. ---------------------------
  40. While working on a project you may find that several assets need to have
  41. the same parameters changed, such as enabling mipmaps, but you only want
  42. those specific parameters changed. To do this, select every asset you want
  43. to reimport in the file system. In the import tab there will now be a
  44. checkbox to the left of every import parameter.
  45. .. image:: img/reimport_multiple.png
  46. Select the checkbox of the parameters you want to change on your imported
  47. assets, then change the parameters normally. Finally, click the reimport
  48. button and every selected asset will be reimported with only those
  49. parameters changed.
  50. Automatic reimport
  51. ------------------
  52. When the MD5 checksum of the source asset changes, Godot will perform an
  53. automatic reimport of it, applying the preset configured for that specific
  54. asset.
  55. Files generated
  56. ---------------
  57. Importing will add an extra ``<asset>.import`` file next to the source file,
  58. containing the import configuration.
  59. **Make sure to commit these files to your version control system**, as these
  60. files contain important metadata.
  61. ::
  62. $ ls
  63. example.png
  64. example.png.import
  65. project.godot
  66. Additionally, extra assets will be present in the hidden
  67. ``res://.godot/imported/`` folder:
  68. ::
  69. $ ls .godot/imported
  70. example.png-218a8f2b3041327d8a5756f3a245f83b.ctex
  71. example.png-218a8f2b3041327d8a5756f3a245f83b.md5
  72. If any of the files present in this folder is erased (or the whole folder), the
  73. asset or assets will be reimported automatically. As such, committing the
  74. ``.godot/`` folder to the version control system is not recommended. While
  75. committing this folder can shorten reimporting time when checking out on another
  76. computer, it requires considerably more space and bandwidth.
  77. The default version control metadata that can be generated on project creation
  78. will automatically ignore the ``.godot/`` folder.
  79. Changing import resource type
  80. -----------------------------
  81. Some source assets can be imported as different types of resources. For this,
  82. select the relevant type of resource desired then click **Reimport**:
  83. .. image:: img/import_process_changing_import_type.webp
  84. .. note::
  85. For technical reasons, the editor must be restarted after changing an import
  86. type in the Import dock.
  87. Changing default import parameters
  88. ----------------------------------
  89. Different types of projects might require different defaults. Changing the import
  90. options to a predefined set of options can be achieved by using the
  91. **Preset...** Menu. Besides some resource types offering presets, the default
  92. settings can be saved and cleared too:
  93. .. image:: img/import_process_change_preset.webp
  94. The default import parameters for a given resource type can be changed
  95. project-wide using the **Import Defaults** tab of the Project Settings dialog:
  96. .. image:: img/import_process_import_defaults.webp
  97. Further reading
  98. ---------------
  99. This workflow takes a little time to get used to, but it enforces a more correct
  100. way to deal with resources.
  101. There are many types of assets available for import. Continue reading to
  102. understand how to work with all of them:
  103. - :ref:`doc_importing_images`
  104. - :ref:`doc_importing_audio_samples`
  105. - :ref:`doc_importing_3d_scenes`
  106. - :ref:`doc_importing_translations`