Work in progress

The content of this page was not yet updated for Godot 4.2 and may be outdated. If you know how to improve this page or you can confirm that it's up to date, feel free to open a pull request.

プロジェクトのエクスポート

エクスポートする理由は?

当初、Godotにはプロジェクトをエクスポートする手段がありませんでした。 開発者は適切なバイナリをコンパイルし、各プラットフォーム用のパッケージを手動でビルドします。

より多くの開発者(さらには非プログラマ)がそれを使用し始め、当社が同時により多くのプロジェクトを取り始めたとき、これがボトルネックであることが明らかになりました。

PC上

Godotを使用してPC上でゲームプロジェクトを配布することはかなり簡単です。Godotバイナリを project.godot ファイルと同じディレクトリにドロップし、プロジェクトディレクトリを圧縮すれば完了です。

これは簡単に聞こえますが、おそらく開発者がこれをしたくない理由がいくつかあります。 1つ目は、ファイルの読み込みを分散することが望ましくない場合があることです。一部の開発者は、好奇心旺盛なゲームユーザーがゲームの作成方法を覗き見るのを好まない場合があり、また他の開発者はゲームが洗練されていないなどと感じるかもしれません。もう1つの理由は、開発者が特別にコンパイルされたバイナリを好む可能性があることです。バイナリはサイズが小さく、より最適化されており、エディタやデバッガなどのツールは含まれません。

Finally, Godot has a simple but efficient system for creating DLCs as extra package files.

モバイル上

モバイルプラットフォームでの同じシナリオは少し厄介です。これらのデバイスでプロジェクトを配布するには、これらの各プラットフォームのバイナリがビルドされ、ゲームデータと共にネイティブプロジェクトに追加されます。

これは、開発者がエクスポートする前に各プラットフォームのSDKに精通している必要があることを意味するため、面倒な場合があります。各SDKを学ぶことは常に奨励されていますが、望ましくない時間にそれを行うことを余儀なくされることはイライラする可能性があります。

There is also another problem with this approach: different devices prefer some data in different formats to run. The main example of this is texture compression. All PC hardware uses S3TC (BC) compression and that has been standardized for more than a decade, but mobile devices use different formats for texture compression, such as ETC1 and ETC2.

エクスポートメニュー

異なるエクスポートワークフローで多くの試みを行った後、現在のワークフローが最適に機能することが実証されています。この執筆時点では、すべてのプラットフォームがまだサポートされているわけではありませんが、サポートされているプラットフォームは引き続き拡張されています。

エクスポートメニューを開くには、[エクスポート]ボタンをクリックします:

../../_images/export.png

エクスポートメニューが開きます。ただし、完全に空の状態です。これは、エクスポートプリセットを追加する必要があるためです。

../../_images/export_dialog.png

エクスポートプリセットを作成するには、エクスポートメニューの上部にある[追加…]ボタンをクリックします。これにより、エクスポートプリセット用に選択できるプラットフォームのドロップダウンリストが開きます。

../../_images/export_preset.png

多くの場合、エクスポートするにはデフォルトのオプションで十分なので、それらを微調整する必要は通常ありません。ただし、多くのプラットフォームでは、エクスポートできるように追加のツール(SDK)をインストールする必要があります。さらに、Godotはパッケージを作成するためにエクスポートテンプレートをインストールする必要があります。エクスポートメニューは、何かが欠けていると文句を言い、ユーザーが解決するまでそのプラットフォームにエクスポートすることを許可しません。

../../_images/export_error.png

その時点で、ユーザーはドキュメントに戻り、そのプラットフォームを適切にセットアップする方法の指示に従うことが期待されます。

エクスポートテンプレート

プラットフォームの設定とは別に、プロジェクトをエクスポートできるようにエクスポートテンプレートをインストールする必要があります。これらは、ウェブサイトのダウンロードページ<https://www.godotengine.org/download> からTPZファイル(名前が変更されたZIPアーカイブ)として取得できます。

ダウンロードしたら、エディタの エクスポートテンプレートの管理 [ファイルからインストール] オプションを使用してインストールできます。

../../_images/exptemp.png

Resource options

エクスポート時に、Godotはエクスポートするすべてのファイルのリストを作成し、パッケージを作成します。エクスポートには3つの異なるモードがあります:

  • プロジェクト内のリソースをすべてエクスポート

  • 選択したシーン(と依存関係にあるもの)をエクスポート

  • 選択したリソース(と依存関係にあるもの)をエクスポート

../../_images/expres.png

Export all resources in the project will export every resource in the project. Export selected scenes and Export selected resources gives you a list of the scenes or resources in the project, and you have to select every scene or resource you want to export.

../../_images/expselected.png

注釈

Files and folders whose name begin with a period will never be included in the exported project. This is done to prevent version control folders like .git from being included in the exported PCK file.

Below the list of resources are two filters that can be setup. The first allows non resource files such as .txt, .json and .csv to be exported with the project. The second filter can be used to exclude every file of a certain type without manually deselecting every one. For example, .png files.

Configuration files

The export configuration is stored in two files that can both be found in the project directory:

  • export_presets.cfg: This file contains the vast majority of the export configuration and can be safely committed to version control. There is nothing in here that you would normally have to keep secret.

  • .godot/export_credentials.cfg: This file contains export options that are considered confidential, like passwords and encryption keys. It should generally not be committed to version control or shared with others unless you know exactly what you are doing.

Since the credentials file is usually kept out of version control systems, some export options will be missing if you clone the project to a new machine. The easiest way to deal with this is to copy the file manually from the old location to the new one.

コマンドラインからエクスポート

制作においては自動ビルドが便利ですが、Godotではコマンドラインのパラメーター--exportおよび--export-debugを使うことで可能になります。コマンドラインからのエクスポートでも、設定のためにエクスポート用プリセットを指定する必要があります。コマンドラインでの基本的な呼び出し方はこうです:

godot --export "Windows Desktop" some_name.exe

This will export to some_name.exe, assuming there is a preset called "Windows Desktop" and the template can be found. (The export preset name must be written within quotes if it contains spaces or special characters.) The output path is relative to the project path or absolute; it does not respect the directory the command was invoked from.

The output file extension should match the one used by the Godot export process:

  • Windows: .exe

  • macOS: .zip (from all platforms) or .dmg (only when exporting from macOS). .app is not supported directly, although the generated ZIP archive contains an .app bundle.

  • Linux: Any extension (including none). .x86_64 is typically used for 64-bit x86 binaries.

  • HTML5: .zip

  • Android: .apk

  • iOS: .zip

You can also configure it to export only the PCK or ZIP file, allowing a single exported main pack file to be used with multiple Godot executables. When doing so, the export preset name must still be specified on the command line:

godot --export-pack "Windows Desktop" some_name.pck

It is often useful to combine the --export flag with the --path flag, so that you do not need to cd to the project folder before running the command:

godot --path /path/to/project --export "Windows Desktop" some_name.exe

参考

See コマンドラインチュートリアル for more information about using Godot from the command line.

PCK versus ZIP pack file formats

Each format has its upsides and downsides. PCK is the default and recommended format for most use cases, but you may want to use a ZIP archive instead depending on your needs.

PCK format:

  • Uncompressed format. Larger file size, but faster to read/write.

  • Not readable and writable using tools normally present on the user's operating system, even though there are third-party tools to extract and create PCK files.

ZIP format:

警告

Due to a known bug, when using a ZIP file as a pack file, the exported binary will not try to use it automatically. Therefore, you have to create a launcher script that the player can double-click or run from a terminal to launch the project:

:: launch.bat (Windows)
@echo off
my_project.exe --main-pack my_project.zip

# launch.sh (Linux)
./my_project.x86_64 --main-pack my_project.zip

Save the launcher script and place it in the same folder as the exported binary. On Linux, make sure to give executable permissions to the launcher script using the command chmod +x launch.sh.