Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

Pack、パッチ、そしてModをエクスポートする

使用事例

ゲームをデプロイした後でも機能を追加したくなる事はよくあります。

例に含まれるのは……

  • ダウンロードコンテンツ: 機能とコンテンツをゲームに追加します。

  • パッチ: 出荷済みの製品に見つかったバグを修正します。

  • Mod: 他の人々でもゲームのコンテンツを製作できるようにします。

これらのツールが、最初のリリース後も開発を続ける助けになるのです。

PCKファイルについて

Godotではこれらをリソースパック機能(PCKファイル、拡張子は.pck)により実現しています。

利点:

  • 段階的なアップデート / パッチ

  • DLCの提供

  • Modサポートの提供

  • Modのためにソースコードの公開は不要

  • プロジェクト構造をよりモジュール化

  • users don't have to replace the entire game

最初の段階では、プロジェクトをエクスポートしたものをプレイヤーに配布します。その後、機能やコンテンツを追加したくなったら、アップデートをPCKファイルでユーザーに配るのです。

制限はありませんが、PCKファイルに通常含まれるのは:

  • スクリプト

  • シーン

  • シェーダー

  • モデル

  • テクスチャ

  • サウンドエフェクト

  • 音楽

  • その他ゲームへのインポートに適したアセット

PCKファイルは全く別のGodotプロジェクトをも含むことができ、元のゲームはそれを実行中に読み込めます。

PCKファイルの生成

In order to pack all resources of a project into a PCK file open the project and go to Project/Export and click on "Export PCK/Zip". Also make sure to have an export template selected while doing so.

../../_images/export_pck.png

もうひとつの方法は、コマンドラインからエクスポートすることです。もし出力ファイル名の終わりがPCKあるいはZIPファイル拡張子の場合、エクスポートプロセスは選んだプラットフォーム向けにファイルをビルドします。

注釈

もしゲームにModを追加できるようにしたい場合、ユーザーにも同様にエクスポートしたファイルを作成してもらう必要があります。元のゲームで、PCK内のリソースは決められたディレクトリ構造に置くようにするか、もしくはスクリプトにMod用のインターフェースを用意してから、次の選択肢は…

  1. ディレクトリ構造かインターフェースについてのドキュメンテーションを公開し、Mod作者たちにGodotエンジンをインストールしてもらい、(確実に動作するように)ドキュメンテーションに定義されたAPIに沿ってModを製作してもらいます。それから、上記の解説どおりにGodot内蔵のエクスポート・ツールにてPCKファイルを作成してもらいます。

  2. The developer uses Godot to build a GUI tool for adding their exact API content to a project. This Godot tool must either run on a tools-enabled build of the engine or have access to one (distributed alongside or perhaps in the original game's files). The tool can then use the Godot executable to export a PCK file from the command line with OS.execute(). The game itself shouldn't use a tool-build of the engine (for security), so it's best to keep the modding tool and game separate.

実行時にPCKファイルを開く

To import a PCK file, one uses the ProjectSettings singleton. The following example expects a “mod.pck” file in the directory of the games executable. The PCK file contains a “mod_scene.tscn” test scene in its root.

func _your_function():
    # This could fail if, for example, mod.pck cannot be found.
    var success = ProjectSettings.load_resource_pack("res://mod.pck")

    if success:
        # Now one can use the assets as if they had them in the project from the start.
        var imported_scene = load("res://mod_scene.tscn")

警告

By default, if you import a file with the same file path/name as one you already have in your project, the imported one will replace it. This is something to watch out for when creating DLC or mods. You can solve this problem by using a tool that isolates mods to a specific mods subfolder. However, it is also a way of creating patches for one's own game. A PCK file of this kind can fix the content of a previously loaded PCK.

To opt out of this behavior, pass false as the second argument to ProjectSettings.load_resource_pack().

注釈

C#プロジェクトの場合、最初にDLLをビルドし、プロジェクトディレクトリに配置する必要があります。次に、リソースパックをロードする前に、次のようにDLLをロードする必要があります: Assembly.LoadFile("mod.dll")

概要

This tutorial explains how to add mods, patches, or DLC to a game. The most important thing is to identify how one plans to distribute future content for their game and develop a workflow that is customized for that purpose. Godot should make that process smooth regardless of which route a developer pursues.