コマンドラインチュートリアル
一部の開発者は、コマンドラインを広範囲に使用することを好みます。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.
コマンドライン リファレンス
アイコン説明
不明なコマンドライン引数は何の効果もないことに注意してください。 指定されたビルドタイプに存在しないコマンドライン引数を使用しても、エンジンは警告**しません**。
一般的なオプション
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>
プロジェクトへのパス (<directory> には「project.godot」ファイルが含まれている必要があります)。
scene <path>
Path or UID of a scene in the project that should be started.
-u , --upwards
「project.godot」ファイルのフォルダを上方向にスキャンします。
--main-pack <file>
読み込むパック (.pck) ファイルへのパス。
--render-thread <mode>
レンダリングスレッドモード ('unsafe', 'safe', 'separate')。詳細については、 Thread Model を参照してください。
--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>
レンダラー名。ドライバーのサポートが必要です。
--rendering-driver <driver>
レンダリングドライバー (ディスプレイドライバーによって異なります)。使用可能なドライバーの一覧を表示するには --help を使用します。
--gpu-index <device_index>
特定の GPU を使用します (使用可能なデバイスリストを取得するには、--verbose で実行します)。
--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>
XR モードを選択します ('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', 'disable')。
--print-fps
1秒あたりのフレーム数を stdout に出力します。
--editor-pseudolocalization
Enable pseudolocalization for the editor and the project manager.
スタンドアロンツール
Command
説明
-s , --script <script>
Run a script. <script> must be a resource path relative to the project (myscript.gd will be interpreted as res://myscript.gd )
or an absolute filesystem path (for example on Windows C:/tmp/myscript.gd )
--main-loop <main_loop_name>
Run a MainLoop specified by its global class name.
--check-only
エラー分析のみ行って終了 (--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 で使用されます)。
--gdscript-docs <path>
エンジン API をダンプするのではなく、<path> にある GDScript ファイル内のインライン ドキュメントから API リファレンスを生成します (--doctool で使用)。
--build-solutions
スクリプトソリューションをビルドします (例: C# プロジェクト用)。 --editor が暗黙的に指定され、編集するには有効なプロジェクトが必要です。
--dump-gdextension-interface
現在のフォルダーに GDExtension ヘッダーファイル 'gdnative_interface.h' を生成します。このファイルは GDExtension を実装するために必要な基本ファイルです。
--dump-extension-api
現在のフォルダーに 'extension_api.json' という名前の GDExtension バインディングの Godot API の JSON ダンプを生成します。
--validate-extension-api <path>
以前のバージョンのエンジンからダンプされたGDExtension API ファイルを検証し (上記のオプションを使用)、API の互換性を確認します。非互換性またはエラーが検出された場合、戻りコードはゼロ以外になります。
--benchmark
実行時間をベンチマークし、コンソールに出力します。
--benchmark-file <path>
実行時間をベンチマークし、JSON 形式で指定されたファイルに保存します。パスは絶対パスにする必要があります。
--test [--help]
Run unit tests. Use --test --help for more information.
パス
godot と入力すればどこからでも簡単に実行できるように、GodotエディタのバイナリをPATH環境変数に含めることをお勧めします。Linuxでこれを行うには、 /usr/local/bin にGodotバイナリを配置し、それが godot として呼び出されるようにします。
Windows または macOS でこれを簡単に実現するには、Scoop (Windows の場合) または Homebrew (macOS の場合) を使用して Godot をインストールします。これにより、インストールされた Godot のコピーが PATH で自動的に使用できるようになります。
Windows macOS
# 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
# Standard editor:
brew install godot
# Editor with C# support (will be available as `godot-mono` in `PATH`):
brew 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 フラグを付けて実行します。これは、プロジェクトディレクトリ内から実行するか、上で説明したようにプロジェクトパスを設定する必要があります。そうしないとコマンドは無視され、プロジェクトマネージャーが表示されます。
project.godot ファイルへのフルパスを渡す場合、 -e フラグは省略できます。
シーンが作成および保存されている場合は、そのシーンを引数として同じコードを実行することで、後で編集できます。
シーンの削除
Godot はファイルシステムと連携しており、追加のメタデータファイルを作成することはありません。シーン ファイルを消去するには rm を使用します。そのシーンを参照するものがないことを確認してください。そうしないと、プロジェクトを開いたときにエラーが発生します。
ゲームの実行
ゲームを実行するには、プロジェクトディレクトリ内または上記で説明したプロジェクトパスを使用して Godot を実行します。
project.godot ファイルを渡すと、ゲームが実行されずに常にエディターが実行されることに注意してください。
特定のシーンをテストする必要がある場合は、そのシーンをコマンドラインに渡します。
デバッグ
コマンドラインはすぐにスクロールしてしまうため、これでエラーを検出するのは困難な場合があります。そのため -d を追加することでコマンドラインデバッガーが利用できるようになっています。これはゲームまたは単一シーンの実行で機能します。
エクスポート
コマンドラインからのプロジェクトのエクスポートもサポートされています。これは継続的インテグレーション(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を実行させることができます: