Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

コマンドラインチュートリアル

一部の開発者は、コマンドラインを広範囲に使用することを好みます。Godotは使いやすく設計されているので、ここでは完全にコマンドラインから作業するための手順を説明します。エンジンが外部ライブラリーにほとんど依存しないことを考えると、初期化時間は非常に速く、このワークフローに適しています。

注釈

WindowsやLinuxでは、ターミナルでGodot binaryの相対パスまたは絶対パスを指定して実行することができます。

On macOS, the process is different due to Godot being contained within a .app bundle (which is a folder, not a file). To run a Godot binary from a terminal on macOS, you have to cd to the folder where the Godot application bundle is located, then run Godot.app/Contents/MacOS/Godot followed by any command line arguments. If you've renamed the application bundle from Godot to another name, make sure to edit this command line accordingly.

コマンドライン リファレンス

アイコン説明

  • リリース エディタビルド、デバッグエクスポートテンプレート、そしてリリースエクスポートテンプレートで使用可能です。

  • デバッグ エディタビルドとデバッグエクスポートテンプレートでのみ使用可能です。

  • extended Only available in editor builds, and export templates compiled with disable_path_overrides=false.

  • エディタ エディタビルドでのみ利用可能です。

不明なコマンドライン引数は何の効果もないことに注意してください。 指定されたビルドタイプに存在しないコマンドライン引数を使用しても、エンジンは警告**しません**。

一般的なオプション

Command

説明

-h, --help

リリース コマンド ラインオプションの一覧を表示します。

--version

リリース バージョン文字列を表示します。

-v, --verbose

リリース 詳細な標準出力モードを使用します。

-q, --quiet

リリース 静かなモード、標準出力メッセージを出力しません。エラーは引き続き表示されます。

--no-header

リリース Do not print engine version and rendering method header on startup.

実行オプション

Command

説明

--, ++

リリース ユーザーが提供した引数の区切りとして使用します。この区切り以降の引数はエンジンによって使用されず、 OS.get_cmdline_user_args() から読み取ることができます。

-e, --editor

エディタ シーンを実行する代わりにエディタを開きます。

-p, --project-manager

エディタ プロジェクトが自動検出された場合でも、プロジェクトマネージャーを開きます。

--recovery-mode

エディタ "Start the editor in recovery mode, which disables features that can typically cause startup crashes, such as tool scripts, editor plugins, GDExtension addons, and others.

--debug-server <uri>

エディタ エディタデバッグサーバーを開始します (<protocol>://<host/IP>[:<port>] 、 または tcp://127.0.0.1:6007)

--dap-port <ポート>

エディタ Use the specified port for the GDScript Debug Adapter Protocol. Recommended port range [1024, 49151].

--lsp-port <ポート>

エディタ Use the specified port for the GDScript Language Server Protocol. Recommended port range [1024, 49151].

--quit

リリース 最初のイテレーションの後に終了します。

--quit-after

リリース 指定された回数のイテレーション後に終了します。無効にするには 0 に設定します。

-l, --language <locale>

リリース 特定のロケールを使用します。 <locale>language_Script_COUNTRY_VARIANT の形式に従います。language は 2 文字または 3 文字の小文字の言語コードで、残りはオプションです。詳細については、Locale codes を参照してください。

--path <directory>

extended Path to a project (<directory> must contain a "project.godot" file).

--scene <path>

extended Path or UID of a scene in the project that should be started.

--main-pack <file>

extended Path to a pack (.pck) file to load.

--render-thread <mode>

リリース Render thread mode ("unsafe", "safe", "separate"). See Thread Model for more details.

--remote-fs <address>

リリース リモートファイルシステム (<host/IP>[:<port>] アドレス)。

--remote-fs-password <password>

リリース リモートファイルシステムのパスワード。

--audio-driver <driver>

リリース オーディオ ドライバー。使用可能なドライバーの一覧を表示するには --help を使用します。

--display-driver <driver>

リリース ディスプレイ ドライバー (およびレンダリング ドライバー)。使用可能なドライバーの一覧を表示するには --help を使用します。

--audio-output-latency <ms>

リリース Override audio output latency in milliseconds (default is 15 ms). Lower values make sound playback more reactive but increase CPU usage, and may result in audio cracking if the CPU can't keep up.

--rendering-method <renderer>

リリース Renderer name. Valid values are forward_plus, mobile, and gl_compatibility. Requires driver support.

--rendering-driver <driver>

リリース レンダリングドライバー (ディスプレイドライバーによって異なります)。使用可能なドライバーの一覧を表示するには --help を使用します。

--gpu-index <device_index>

リリース Use a specific GPU (only available on the Forward+/Mobile renderers; run with --verbose to get available device list).

--text-driver <driver>

リリース テキストドライバー (フォント、BiDi、シェーピング)。

--tablet-driver <driver>

リリース ペンタブレット入力ドライバー。

--headless

リリース ヘッドレスモードを有効にします (--display-driver headless --audio-driver Dummy)。サーバー用途、もしくは --script と一緒に使用します。

--log-file

リリース Write output/error log to the specified path instead of the default location defined by the project. <file> path should be absolute or relative to the project directory.

--write-movie <file>

リリース エンジンをムービー出力モードで実行します (通常は .avi または .png 拡張子)。 --fixed-fps はムービーの FPS を指定するために使用できます。 --disable-vsync はムービーの書き込みを高速化できますが、ゲームの操作が難しくなります。 --quit-after を使用すると、書き込むフレーム数を指定できます。

表示オプション

Command

説明

-f, --fullscreen

リリース フルスクリーンモードを指定します。

-m, --maximized

リリース ウィンドウの最大化を指定します。

-w, --windowed

リリース ウィンドウモードを指定します。

-t, --always-on-top

リリース ウィンドウを常時最前面に表示するように指定します。

--resolution <W>x<H>

リリース ウィンドウの解像度を指定します。

--position <X>,<Y>

リリース ウィンドウの位置を指定します。

--screen <N>

リリース ウィンドウを表示する画面の番号を指定します。

--single-window

リリース 単一のウィンドウを使用します (個別のサブウィンドウはありません)。

--xr-mode <mode>

リリース Select XR mode ("default", "off", "on").

--wid <window_id>

リリース Request parented to window.

--accessibility <mode>

リリース Select accessibility mode ['auto" (when screen reader is running, default), "always", "disabled'].

デバッグオプション

Command

説明

-d, --debug

リリース デバッグ (ローカル stdout デバッガー)。

-b, --breakpoints

リリース ブレークポイントとしてソースの行番号をカンマで区切って列挙します。スペースは使えません (代わりに %20 を使用できます)。

--ignore-error-breaks

リリース If debugger is connected, prevents sending error breakpoints.

--profiling

リリース スクリプトデバッガーでプロファイリングを有効にします。

--gpu-profile

リリース フレームのレンダリング中に最も時間がかかったタスクの GPU プロファイルを表示します。

--gpu-validation

リリース デバッグ用にグラフィック API の 検証レイヤー を有効にします。

--gpu-abort

デバッグ GPU エラー (通常は検証レイヤーエラー) が発生した場合に停止します。システムがフリーズした場合に問題を確認するのに役立つ場合があります。

--generate-spirv-debug-info

デバッグ Generate SPIR-V debug information. This allows source-level shader debugging with RenderDoc.

--extra-gpu-memory-tracking

デバッグ Enables additional memory tracking (see class reference for RenderingDevice.get_driver_and_device_memory_report() and linked methods). Currently only implemented for Vulkan. Enabling this feature may cause crashes on some systems due to buggy drivers or bugs in the Vulkan Loader. See https://github.com/godotengine/godot/issues/95967

--accurate-breadcrumbs

デバッグ Force barriers between breadcrumbs. Useful for narrowing down a command causing GPU resets. Currently only implemented for Vulkan.

--remote-debug <uri>

リリース リモートデバッグ (<protocol>://<host/IP>[:<port>] 、例: tcp://127.0.0.1:6007)。

--single-threaded-scene

リリース シーンツリーはシングルスレッドモードで実行されます。サブスレッドグループは無効になり、メインスレッドで実行されます。

--debug-collisions

デバッグ シーンを実行する際にコリジョン形状を表示する。

--debug-paths

デバッグ シーンの実行時にパスラインを表示します。

--debug-navigation

デバッグ シーンを実行する際にナビゲーション・ポリゴンを表示する。

--debug-avoidance

デバッグ シーンの実行時にナビゲーション回避のデバッグビジュアルを表示します。

--debug-stringnames

デバッグ エンジンが終了したときに、すべての StringName 割り当てを stdout に出力します。

--debug-canvas-item-redraw

デバッグ Display a rectangle each time a canvas item requests a redraw (useful to troubleshoot low processor mode).

--max-fps <fps>

リリース Set a maximum number of frames per second rendered (can be used to limit power usage). A value of 0 results in unlimited framerate.

--frame-delay <ms>

リリース Simulate high CPU load (delay each frame by <ms> milliseconds). Do not use as a FPS limiter; use --max-fps instead.

--time-scale <scale>

リリース タイムスケールの強制 (値が大きいほど早く、1.0が標準)。

--disable-vsync

リリース プロジェクト設定で有効になっている場合でも、垂直同期(V-Sync)を強制的に無効にします。ドライバーレベルの V-Sync 強制は上書きされません。

--disable-render-loop

リリース 描画ループを無効にして、スクリプトから明示的に呼び出された場合にのみレンダリングが行われるようにします。

--disable-crash-handler

リリース プラットフォーム・コードが対応している場合もクラッシュ・ハンドラを無効にする。

--fixed-fps <fps>

リリース フレーム毎秒の固定。この設定によりリアルタイム同期は無効化。

--delta-smoothing <enable>

リリース Enable or disable frame delta smoothing ("enable", "disable").

--print-fps

リリース 1秒あたりのフレーム数を stdout に出力します。

--editor-pseudolocalization

エディタ Enable pseudolocalization for the editor and the project manager.

スタンドアロンツール

Command

説明

-s, --script <script>

extended Run a script. <script> must be a resource path relative to the project (myscript.gd will be interpreted as res://my_script.gd) or an absolute filesystem path (for example, on Windows: C:/tmp/my_script.gd).

--main-loop <main_loop_name>

extended Run a MainLoop specified by its global class name.

--check-only

extended Only parse for errors and quit (use with --script).

--import

エディタ エディタを起動し、リソースがインポートされるのを待ってから終了します。 --editor および --quit も暗黙的に使用されます。

--export-release <preset> <path>

エディタ Export the project in release mode using the given preset and output path. The preset name should match one defined in "export_presets.cfg". <path> should be absolute or relative to the project directory, and include the filename for the binary (e.g. "builds/game.exe"). The target directory must exist.

--export-debug <preset> <path>

エディタ --export-release と似ていますが、デバッグテンプレートを使用します。 --import も暗黙的に使用されます。

--export-pack <preset> <path>

エディタ --export-release と似ていますが、指定されたプリセットのゲームパックのみをエクスポートします。 <path> の拡張子によって、PCK 形式か ZIP 形式かが決まります。 --import も暗黙的に使用されます。

--export-patch <preset> <path>

エディタ Export pack with changed files only. See --export-pack description for other considerations.

--patches <paths>

エディタ List of patches to use with --export-patch. The list is comma-separated.

--install-android-build-template

エディタ Install the Android build template. Used in conjunction with --export-release or --export-debug.

--convert-3to4 [<max_file_kb>] [<max_line_size>]

エディタ プロジェクトを Godot 3.x から Godot 4.x に変換します。

--validate-conversion-3to4 [<max_file_kb>] [<max_line_size>]

エディタ プロジェクトを Godot 3.x から Godot 4.x に変換するときに名前が変更される要素を表示します。

--doctool [<path>]

エディタ 指定された <path> へのエンジン API 参照を XML 形式でダンプし、既存のファイルが見つかった場合はマージします。

--no-docbase

エディタ 基本型のダンプを禁止します (--doctool で使用されます)。

--gdextension-docs

エディタ Rather than dumping the engine API, generate API reference from all the GDExtensions loaded in the current project (used with --doctool).

--gdscript-docs <path>

エディタ Rather than dumping the engine API, generate API reference from the inline documentation in the GDScript files found in <path> (used with --doctool).

--build-solutions

エディタ スクリプトソリューションをビルドします (例: C# プロジェクト用)。 --editor が暗黙的に指定され、編集するには有効なプロジェクトが必要です。

--dump-gdextension-interface

エディタ Generate GDExtension header file "gdextension_interface.h" in the current folder. This file is the base file required to implement a GDExtension.

--dump-gdextension-interface-json

エディタ Generate a JSON dump of the GDExtension interface named "gdextension_interface.json" in the current folder.

--dump-extension-api

エディタ Generate JSON dump of the Godot API for GDExtension bindings named "extension_api.json" in the current folder.

--dump-extension-api-with-docs

エディタ Generate JSON dump of the Godot API like the previous option, but including documentation.

--validate-extension-api <path>

エディタ 以前のバージョンのエンジンからダンプされたGDExtension API ファイルを検証し (上記のオプションを使用)、API の互換性を確認します。非互換性またはエラーが検出された場合、戻りコードはゼロ以外になります。

--benchmark

エディタ 実行時間をベンチマークし、コンソールに出力します。

--benchmark-file <path>

エディタ 実行時間をベンチマークし、JSON 形式で指定されたファイルに保存します。パスは絶対パスにする必要があります。

--test [--help]

エディタ Run unit tests (requires compiling the engine with tests=yes). Use --test --help for more information.

パス

godot と入力すればどこからでも簡単に実行できるように、GodotエディタのバイナリをPATH環境変数に含めることをお勧めします。Linuxでこれを行うには、 /usr/local/bin にGodotバイナリを配置し、それが godot として呼び出されるようにします。

Windows または macOS でこれを簡単に実現するには、Scoop (Windows の場合) または Homebrew (macOS の場合) を使用して Godot をインストールします。これにより、インストールされた Godot のコピーが PATH で自動的に使用できるようになります。

# Add "Extras" bucket
scoop bucket add extras

# Standard editor:
scoop install godot

# Editor with C# support (will be available as `godot-mono` in `PATH`):
scoop install godot-mono

プロジェクトパスの設定

Godotバイナリの場所と現在の作業ディレクトリによっては、次のコマンドを正しく機能させるためにプロジェクトへのパスを設定する必要があります。

エディタを実行する際に、プロジェクトの project.godot ファイルへのパスを第1引数として指定してこれを実現できます:

godot path_to_your_project/project.godot [other] [commands] [and] [args]

すべてのコマンドでは、 --path 引数を使用してこれを実行できます:

godot --path path_to_your_project [other] [commands] [and] [args]

たとえば、ゲームをエクスポートするための完全なコマンド(以下に説明する)は次のようになります:

godot --headless --path path_to_your_project --export-release my_export_preset_name game.exe

プロジェクトのサブディレクトリから開始する場合は、Godot の --upwards 引数を使用して、親ディレクトリを再帰的に検索し、 project.godot ファイルを自動的に見つけます。

たとえば、作業ディレクトリが同じパスにある場合、サブディレクトリにネストされたシーン (以下で説明) を実行すると、次のようになります。

godot --upwards nested_scene.tscn

プロジェクトの作成

コマンドラインからプロジェクトを作成するには、シェルを目的の場所に移動して project.godot ファイルを作成します。

mkdir newgame
cd newgame
touch project.godot

これで、Godotでプロジェクトを開くことができます。

エディタの実行

エディタを実行するには、Godotに -e フラグを付けて実行します。これは、プロジェクトディレクトリ内から実行するか、上で説明したようにプロジェクトパスを設定する必要があります。そうしないとコマンドは無視され、プロジェクトマネージャーが表示されます。

godot -e

project.godot ファイルへのフルパスを渡す場合、 -e フラグは省略できます。

シーンが作成および保存されている場合は、そのシーンを引数として同じコードを実行することで、後で編集できます。

godot -e scene.tscn

シーンの削除

Godot はファイルシステムと連携しており、追加のメタデータファイルを作成することはありません。シーン ファイルを消去するには rm を使用します。そのシーンを参照するものがないことを確認してください。そうしないと、プロジェクトを開いたときにエラーが発生します。

rm scene.tscn

ゲームの実行

ゲームを実行するには、プロジェクトディレクトリ内または上記で説明したプロジェクトパスを使用して Godot を実行します。

godot

project.godot ファイルを渡すと、ゲームが実行されずに常にエディターが実行されることに注意してください。

特定のシーンをテストする必要がある場合は、そのシーンをコマンドラインに渡します。

godot scene.tscn

デバッグ

コマンドラインはすぐにスクロールしてしまうため、これでエラーを検出するのは困難な場合があります。そのため -d を追加することでコマンドラインデバッガーが利用できるようになっています。これはゲームまたは単一シーンの実行で機能します。

godot -d
godot -d scene.tscn

エクスポート

コマンドラインからのプロジェクトのエクスポートもサポートされています。これは継続的インテグレーション(CI)のセットアップに特に便利です。

注釈

GPU アクセスのないプラットフォーム (継続的インテグレーションなど) では、 --headless コマンドライン引数の使用が 必須 です。GPU アクセスのあるプラットフォームでは、 --headless によりプロジェクトのエクスポート中にウィンドウが起動されなくなります。

# `godot` must be a Godot editor binary, not an export template.
# Also, export templates must be installed for the editor
# (or a valid custom export template must be defined in the export preset).
godot --headless --export-release "Linux/X11" /var/builds/project
godot --headless --export-release Android /var/builds/project.apk

プリセット名はプロジェクトの export_presets.cfg ファイルで定義されたエクスポートプリセットの名前と一致しなければなりません。もし、プリセット名がスペースや特殊文字を含んでいる場合 ("Windows Desktop"のような)、クォート ("や') で囲まれている必要があります。

ゲームのデバッグバージョンをエクスポートするには、 --export-release の代わりに --export-debug スイッチを使用します。パラメーターと使用方法は同じです。

PCKファイルのみをエクスポートしたい場合、 --export-release または --export-debug の代わりに --export-pack を用い、後ろにプリセット名と拡張子付きの出力パスを付けてください。出力パスの拡張子によって、パッケージの形式 (PCK または ZIP) が決まります。

警告

--export-release--export-debug--export-pack を使用する際にパスを相対パスで指定する場合、パスはカレントディレクトリに対する相対パスではなく、 project.godot ファイルを含むディレクトリに対する相対パスになります。

スクリプトの実行

コマンドラインから .gd スクリプトを実行することができます。この機能はアセットのバッチ変換やカスタムのインポート/エクスポートなど、大規模なプロジェクトで特に役立ちます。

スクリプトは SceneTree または MainLoop から継承する必要があります。

以下は sayhello.gd のサンプルで、どのように動作するかを示しています。

#!/usr/bin/env -S godot -s
extends SceneTree

func _init():
    print("Hello!")
    quit()

実行方法:

# Prints "Hello!" to standard output.
godot -s sayhello.gd

パスに project.godot が存在しない場合は、現在のパスが現在の作業ディレクトリであると見なされます (-path が指定されている場合を除く)。

The script path will be interpreted as a resource path relative to the project, here res://sayhello.gd. You can also use an absolute filesystem path instead, which is useful if the script is located outside of the project directory.

上記の``sayhello.gd`` の最初の行は、一般に シェバング と呼ばれます。シェバングを書くことにより、最近のLinuxとmacOSでは、あなたの PATH にあるGodotのバイナリが godot であるとき、スクリプトを次のように実行できます:

# Mark script as executable.
chmod +x sayhello.gd
# Prints "Hello!" to standard output.
./sayhello.gd

もし上記の例があなたのLinuxかmacOSのバージョンで動かない場合、次のようにGodotの場所を直接指定することで、どんなときでもシェバングにGodotを実行させることができます:

#!/usr/bin/godot -s