MySys22.DialogueSystem
ドキュメント
1.0
エンジン
0.5 BETA
エディタ
0.5 BETA
更新
2026-09-28

3. プレゼンテーション(IDialogueView)

3.1 インターフェースのコントラクト

IDialogueView インターフェースを実装すると、既定のプレゼンテーションを置き換えることができます。登録が完了すると、エンジンは自身のビューを使用しなくなります。このインターフェースは、3.2 の例で実装されているとおり、次のメンバーを公開します: IsPanelVisible、SetPanelVisible(bool visible)、ShowText(string speaker, string text)、ShowText(string text)、SetSpeaker(string speaker)、SetText(string text)、HideText()、HideChoices()。

3.2 カスタムビューの実装

例

using MySys22.Engine.API;

public class MyDialogueView : MonoBehaviour, IDialogueView
{
    [SerializeField] private GameObject panel;
    [SerializeField] private TMP_Text speakerLabel;
    [SerializeField] private TMP_Text textLabel;

    public bool IsPanelVisible => panel.activeSelf;

    public void SetPanelVisible(bool visible) => panel.SetActive(visible);
    public void ShowText(string speaker, string text) { speakerLabel.text = speaker; textLabel.text = text; }
    public void ShowText(string text) => ShowText(null, text);
    public void SetSpeaker(string speaker) => speakerLabel.text = speaker;
    public void SetText(string text) => textLabel.text = text;
    public void HideText() => textLabel.text = string.Empty;
    public void HideChoices() { /* ボタンを破棄または非表示にする */ }

    void Awake() => Dialogue.SetView(this);
}

3.3 ビューの解決規則

エンジンはビューに義務を課しません。登録されたビューが存在しない場合、エンジンはシーンに存在すれば DialogueUICanvas を使用し、そうでなければ DialogueOverlayUI を使用します。

3.4 EventSystem の要件

DialogueUICanvas と DialogueOverlayUI は、EventSystem が存在しない場合にこれを作成します。存在しない場合、選択肢のボタンがポインターイベントを受け取らないためです。uGUI のボタンに基づくカスタムビューでは、EventSystem が存在する必要があります。