data_paths.rst 3.9 KB

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