data_paths.rst 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. .. _doc_data_paths:
  2. Data paths
  3. ==========
  4. Path separators
  5. ---------------
  6. For the sake of supporting as many platforms as possible, Godot only
  7. accepts UNIX-style path separators (``/``). These work on all
  8. platforms, including Windows.
  9. A path like ``C:\Projects`` will become ``C:/Projects``.
  10. Resource path
  11. -------------
  12. As mentioned in the :ref:`doc_command_line_tutorial`, Godot considers that
  13. a project exists in any given folder that contains a ``project.godot``
  14. text file, even if such file is empty.
  15. You can access any file relative to it by writing paths starting with
  16. ``res://``, which stands for resources. For example, you can access an image
  17. file ``character.png`` located in the project's root folder in code with the
  18. following path: ``res://character.png``.
  19. User path (persistent data)
  20. ---------------------------
  21. While the project is running, it is a common scenario that the
  22. resource path will be read-only, due to it being inside a package,
  23. self-contained executable, or system-wide install location.
  24. Storing persistent files in such scenarios should be done by using the
  25. ``user://`` prefix, for example: ``user://game_save.txt``.
  26. On some devices (for example, mobile and consoles), this path is unique
  27. to the project. On desktop operating systems, the engine uses the
  28. typical ``~/.local/share/godot/app_userdata/Name`` on macOS and Linux,
  29. and ``%APPDATA%/Name`` on Windows. ``Name`` is taken from the
  30. application name defined in the Project Settings, but it can be
  31. overridden on a per-platform basis using
  32. :ref:`feature tags <doc_feature_tags>`.
  33. Editor data paths
  34. -----------------
  35. The editor uses different paths for user data, user settings and cache depending
  36. on the platform. By default, these paths are:
  37. +---------------+---------------------------------------------------+
  38. | Type | Location |
  39. +===============+===================================================+
  40. | User data | - Windows: ``%APPDATA%\Godot\`` |
  41. | | - macOS: ``~/Library/Application Support/Godot/`` |
  42. | | - Linux: ``~/.local/share/godot/`` |
  43. +---------------+---------------------------------------------------+
  44. | User settings | - Windows: ``%APPDATA%\Godot\`` |
  45. | | - macOS: ``~/Library/Application Support/Godot/`` |
  46. | | - Linux: ``~/.config/godot/`` |
  47. +---------------+---------------------------------------------------+
  48. | Cache | - Windows: ``%TEMP%\Godot\`` |
  49. | | - macOS: ``~/Library/Caches/Godot/`` |
  50. | | - Linux: ``~/.cache/godot/`` |
  51. +---------------+---------------------------------------------------+
  52. - **User data** contains export templates and project-specific data.
  53. - **User settings** contains editor settings, text editor themes,
  54. script templates, etc.
  55. - **Cache** contains temporary data. It can safely be removed
  56. when Godot is closed.
  57. Godot complies with the `XDG Base Directory Specification
  58. <https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html>`__
  59. on all platforms. Environment variables can be overridden as per
  60. the specification to change the editor (and project) data paths.
  61. .. note:: If you use
  62. `Godot packaged as a Flatpak <https://flathub.org/apps/details/org.godotengine.Godot>`__,
  63. the editor data paths will be located in subfolders in
  64. ``~/.var/app/org.godotengine.Godot/``.
  65. .. _doc_data_paths_self_contained_mode:
  66. Self-contained mode
  67. ~~~~~~~~~~~~~~~~~~~
  68. If you create a file called ``._sc_`` or ``_sc_`` in the same directory as the
  69. editor binary, Godot will enable *self-contained mode*. This will make Godot
  70. write all user data to a directory named ``editor_data/`` in the same directory
  71. as the editor binary. This is useful to create a "portable" installation,
  72. which can then be placed on an USB drive.
  73. The `Steam release of Godot <https://store.steampowered.com/app/404790/>`__
  74. uses self-contained mode by default.