数据路径

路径分隔符

For the sake of supporting as many platforms as possible, Godot only accepts UNIX-style path separators (/). These work on all platforms, including Windows.

C:\Projects 这样的路径将变成 C:/Projects

资源路径

As mentioned in the 命令行教程, Godot considers that a project exists in any given folder that contains a project.godot text file, even if such file is empty.

访问项目文件可以通过打开以 res:// 为基的任何路径来实现。例如,位于项目文件夹根部的纹理可以从以下路径打开: res://some_texture.png

用户路径(持久化数据)

当项目运行时,由于资源位于一个压缩包内、自包含可执行文件或系统范围的安装位置,因此通常情况下资源路径是只读的。

在这种情况下,应该通过使用 user:// 前缀来存储持久文件,例如 user://game_save.txt

在某些设备(例如,移动设备和游戏机)上,对项目来说此路径是唯一的。 在桌面操作系统上,引擎在macOS和Linux上使用典型的 ~/.local/share/godot/app_userdata/Name 路径,在Windows上使用 %APPDATA%/Name 路径来表示用户路径。 Name 取自项目设置中定义的应用程序名称,但它可被 feature tags 命令覆写 。

Editor data paths

The editor uses different paths for user data, user settings and cache depending on the platform. By default, these paths are:

类型位置
User data
  • Windows: %APPDATA%\Godot\
  • macOS: ~/Library/Application Support/Godot/
  • Linux: ~/.local/share/godot/
User settings
  • Windows: %APPDATA%\Godot\
  • macOS: ~/Library/Application Support/Godot/
  • Linux: ~/.config/godot/
缓存
  • Windows: %TEMP%\Godot\
  • macOS: ~/Library/Caches/Godot/
  • Linux: ~/.cache/godot/
  • User data contains export templates and project-specific data.
  • User settings contains editor settings, text editor themes, script templates, etc.
  • Cache contains temporary data. It can safely be removed when Godot is closed.

Godot complies with the XDG Base Directory Specification on all platforms. Environment variables can be overridden as per the specification to change the editor (and project) data paths.

注解

If you use Godot packaged as a Flatpak, the editor data paths will be located in subfolders in ~/.var/app/org.godotengine.Godot/.

Self-contained mode

If you create a file called ._sc_ or _sc_ in the same directory as the editor binary, Godot will enable self-contained mode. This will make Godot write all user data to a directory named editor_data/ in the same directory as the editor binary. This is useful to create a “portable” installation, which can then be placed on an USB drive.

The Steam release of Godot uses self-contained mode by default.