File paths in Godot projects¶
This page explains how file paths work inside Godot projects. You will learn how
to access paths in your projects using the res://
and user://
notations
and where Godot stores user files on your hard-drive.
パスの区切り記号¶
To as many platforms as possible, Godot only accepts UNIX-style path separators
(/
). These work on all platforms, including Windows.
Instead of writing paths like C:\Projects
, in Godot, you should write
C:/Projects
.
Accessing files in the project folder¶
Godot considers that a project exists in any folder that contains a
project.godot
text file, even if the file is empty. The folder that contains
this file is your project's root folder.
You can access any file relative to it by writing paths starting with
res://
, which stands for resources. For example, you can access an image
file character.png
located in the project's root folder in code with the
following path: res://some_texture.png
.
Accessing persistent user data¶
To store persistent data files, like the player's save or settings, you want to
use user://
instead of res://
as your path's prefix. This is because
when the game is running, the project's file system will likely be read-only.
The user://
prefix points to a different directory on the user's device. On
mobile and consoles, this path is unique to the project. On desktop, the engine
stores user files in ~/.local/share/godot/app_userdata/[project_name]
on
Linux, ~/Library/Application Support/Godot/app_userdata/[project_name]
on
macOS (since Catalina) and %APPDATA%\Godot\app_userdata\[project_name]
on Windows.
[project_name]
is based on the application name defined in the Project Settings, but
you can override it on a per-platform basis using feature tags.
On HTML5 exports, user://
will refer to a virtual filesystem stored on the
device via IndexedDB. (Interaction with the main filesystem can still be performed
through the JavaScript singleton.)
エディタデータのパス¶
The editor uses different paths for user data, user settings, and cache, depending on the platform. By default, these paths are:
タイプ(型) |
場所(Location) |
---|---|
ユーザーデータ |
|
User data
(when |
|
ユーザー設定 |
|
キャッシュ |
|
ユーザーデータ には、エクスポートテンプレートとプロジェクト固有のデータが含まれます。
ユーザー設定 には、エディタ設定、テキストエディタのテーマ、スクリプトテンプレートなどが含まれます。
キャッシュ には一時データが含まれます。 Godotを閉じたときに安全に削除できます。
Godot complies with the XDG Base Directory Specification on all platforms. You can override environment variables following the specification to change the editor and project data paths.
注釈
フラットパック(Flatpak)としてパッケージ化されたGodot を使用する場合、エディタのデータパスは ~/.var/app/org.godotengine.Godot/
のサブフォルダに配置されます。
自己完結型モード¶
If you create a file called ._sc_
or _sc_
in the same directory as the
editor binary, Godot will enable self-contained mode. This mode makes Godot
write all user data to a directory named editor_data/
in the same directory
as the editor binary. You can use it to create a portable installation of the
editor.
Steam用にリリースされるGodot は、デフォルトで自己完結型モードを使用します。