Game Framework
Game Framework
Section titled “Game Framework”Unity でのゲーム開発を素早く進められるように設計された、 事前構築済みシステムと拡張機能のコレクションです。
このフレームワークは、さまざまなマネージャーやシステムを含む
中央静的クラス GameFramework.Core を基準に構成されています。
UPM Installation
Section titled “UPM Installation”- Unity Package Manager (
Window > Package Manager) を開きます。 - 左上の
+アイコンをクリックし、Add package from git URL...を選びます。 - 次の URL を入力します。
https://github.com/achieveonepark/game-framework.git
Dependencies
Section titled “Dependencies”このフレームワークは、全機能を使用するためにいくつかの外部パッケージへ依存しています。
Required
Section titled “Required”- UniTask:
フレームワーク全体で非同期処理を扱うために必須です。
Game Framework パッケージをインストールする 前に必ず導入 してください。
Optional
Section titled “Optional”以下のパッケージは追加機能を有効にするため、必要に応じて導入できます。
- UniTaskPubSub:
リアクティブ(イベントベース)UI のためのUIBindingManager機能を有効にします。 - QuickSave:
Core.Playerのデータ永続化機能を有効にします。
使用するには、プロジェクトの Scripting Define Symbols にUSE_QUICK_SAVEを追加する必要があります。
Features & API
Section titled “Features & API”フレームワーク内の大半のモジュールは、
静的クラス GameFramework.Core の入れ子クラスとして提供されます。
Access Patterns
Section titled “Access Patterns”- Static Classes
直接アクセスします(例:Core.Time.TimeScale) - MonoBehaviour Singletons
Instanceプロパティ経由でアクセスします
(例:Core.Sound.Instance.PlayBGM())
→ 対応する GameObject がシーン内に存在している必要があります。
System Modules
Section titled “System Modules”| クラス | アクセス方式 | 説明 |
|---|---|---|
Core.Log | Static | さまざまなレベルのコンソールログ出力を処理します。 |
Core.Config | Static | PlayerPrefs に保存されるキー・値設定を管理します。 |
Core.Player | Static | Container ベースのランタイムプレイヤーデータ中央管理クラスです。 |
Core.Time | Static | グローバルなタイムスケール制御と現在時刻の取得を行います。 |
Core.Scene | Singleton | シーンのロードとアンロードを管理します。 |
Core.Popup | Singleton | UI ポップアップの生成とライフサイクルを管理します。 |
Other Features
Section titled “Other Features”- ユーティリティおよび拡張メソッド
Unity と C# の基本型に対するさまざまな拡張メソッドを提供します。
Runtime/Extensionsフォルダを参照してください。 - UI コンポーネント
SafeAreaやDraggableのような UI 補助コンポーネントを含みます。
Quick Start Examples
Section titled “Quick Start Examples”Core.Log
Section titled “Core.Log”カテゴリ別のコンソールログを扱います。
Core.Log.Debug("これはデバッグメッセージです。");Core.Log.Info("重要な情報を出力するためのログです。");Core.Log.Warning("問題が発生する可能性があります。");Core.Config
Section titled “Core.Config”PlayerPrefs に保存される簡単なデータを管理します。
// キーが存在しない場合は初期値を設定Core.Config.AddKey("BGMVolume", 0.8f);
// 値の設定と取得Core.Config.SetConfig("BGMVolume", 0.7f);float currentVolume = (float)Core.Config.GetConfig("BGMVolume");Core.Player (データ管理)
Section titled “Core.Player (データ管理)”コンテナクラスを通してランタイムデータを管理します。
- データとコンテナを定義する
// 実際のデータ構造public class CharacterData : PlayerDataBase{ public string Name; public int Level;}
// データを保持するコンテナpublic class CharacterDataContainer : PlayerDataContainerBase<int, CharacterData>{ public CharacterDataContainer() { // 重要: GetContainer<T> を使うために // DataKey は必ずクラス名と同じでなければなりません。 DataKey = typeof(CharacterDataContainer).Name; }}- コンテナを登録して使う
// ゲーム開始時にコンテナを生成して登録var characterContainer = new CharacterDataContainer();characterContainer.Add(1, new CharacterData { Id = 1, Name = "Hero", Level = 1 });Core.Player.AddContainer(characterContainer);
// 別の場所からデータを取得して利用var myChars = Core.Player.GetContainer<CharacterDataContainer>();var mainChar = myChars.GetInfo(1);mainChar.Level++;
// 全データの保存 / 読み込み(USE_QUICK_SAVE が必要)Core.Player.Save();Core.Player.Load();Core.Popup (Singleton)
Section titled “Core.Popup (Singleton)”Core.Popup スクリプトとポップアッププレハブ一覧を持つ PopupManager GameObject が必要です。
// マネージャーに登録された特定タイプのポップアップを開く// Open() は自動で呼ばれます。var myPopup = Core.Popup.Instance.Open<MyAwesomePopup>();
// ポップアップを開くときにデータを渡すvar data = new MyPopupData { Message = "Hello!" };Core.Popup.Instance.Open<MyAwesomePopup>(data);
// ポップアップを閉じるmyPopup.Close();Core.Time
Section titled “Core.Time”Unity の Time と、Ping を使って取得した時刻の DateTime を包むラッパークラスです。
// ゲーム速度を 2 倍に設定Core.Time.TimeScale = 2.0f;
// 現在の実時間を取得DateTime now = Core.Time.Now;