NOA DebuggerNOA Debugger
  • v1.7.0
  • v1.6.1
  • v1.5.0
  • v1.4.0
  • v1.3.0
  • v1.2.0
  • v1.1.1
  • v1.0.0
Demo
Contact
Buy
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • v1.7.0
  • v1.6.1
  • v1.5.0
  • v1.4.0
  • v1.3.0
  • v1.2.0
  • v1.1.1
  • v1.0.0
Demo
Contact
Buy
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • 日本語
  • English
  • CustomInformationRegister

CustomInformationRegister

このクラスを介して、カスタムデータの登録や削除などを行うことができます。

カスタムデータの登録

以下のAPIを利用することで、カスタムデータを追加できます。
※ NOA Debuggerが提供する機能を利用する場合は、必ずNOA_DEBUGGERのシンボル定義を利用してください。

グループの登録

// カスタムデータグループを追加します。
CustomInformationregister.AddGroup(string name, string displayName = "", int order = Int32.MaxValue);

登録済みのグループ名を指定した場合はキー重複のExceptionが発生します。

データの登録

// 読み取り専用のカスタムデータを追加します。
CustomInformationRegister.AddImmutableIntKeyValue(string groupName, string keyName, Func<int> getValue, string displayName = "", int order = Int32.MaxValue);
CustomInformationRegister.AddImmutableFloatKeyValue(string groupName, string keyName, Func<float> getValue, string displayName = "", int order = Int32.MaxValue);
CustomInformationRegister.AddImmutableStringKeyValue(string groupName, string keyName, Func<string> getValue, string displayName = "", int order = Int32.MaxValue);
CustomInformationRegister.AddImmutableBoolKeyValue(string groupName, string keyName, Func<bool> getValue, string displayName = "", int order = Int32.MaxValue);
CustomInformationRegister.AddImmutableEnumKeyValue(string groupName, string keyName, Func<Enum> getValue, string displayName = "", int order = Int32.MaxValue);

// 変更可能なカスタムデータを追加します。
CustomInformationRegister.AddMutableIntKeyValue(string groupName, string keyName, Func<int> getValue, Action<int> setValue, string displayName = "", int order = Int32.MaxValue);
CustomInformationRegister.AddMutableFloatKeyValue(string groupName, string keyName, Func<float> getValue, Action<float> setValue, string displayName = "", int order = Int32.MaxValue);
CustomInformationRegister.AddMutableStringKeyValue(string groupName, string keyName, Func<string> getValue, Action<string> setValue, string displayName = "", int order = Int32.MaxValue);
CustomInformationRegister.AddMutableBoolKeyValue(string groupName, string keyName, Func<bool> getValue, Action<bool> setValue, string displayName = "", int order = Int32.MaxValue);
CustomInformationRegister.AddMutableEnumKeyValue(string groupName, string keyName, Func<Enum> getValue, Action<Enum> setValue, string displayName = "", int order = Int32.MaxValue);

同一グループ内で登録済みのキー名を指定した場合はキー重複のExceptionが発生します。

サンプルコード

#if NOA_DEBUGGER
using NoaDebugger;
#endif

public class Example
{
    // カスタムデータの値
    private string sampleStringValue = "SampleValue";
    private int sampleIntValue = 1;

    void ExampleMethod()
    {
#if NOA_DEBUGGER

        // カスタムデータグループを追加します
        string groupName = "SampleGroup";
        CustomInformationRegister.AddGroup(
            name: groupName,
            displayName: "SampleGroupDisplayName",
            order: 0);

        // 読み取り専用のカスタムデータを追加します
        CustomInformationRegister.AddImmutableStringKeyValue(
            groupName: groupName,
            keyName: "SampleKey",
            getValue: () => sampleStringValue,
            displayName: "SampleDisplayName",
            order: 0);

        // 変更可能なカスタムデータを追加します
        CustomInformationRegister.AddMutableIntKeyValue(
            groupName: groupName,
            keyName: "MutableSampleKey",
            getValue: () => sampleIntValue,
            setValue: value => sampleIntValue = value,
            displayName: "MutableSampleDisplayName",
            order: 1);
#endif
    }
}

カスタムデータの削除

以下のAPIを呼び出すことで、追加済みのカスタムデータを削除できます。

// 指定されたキー名のカスタムデータを削除します
CustomInformationRegister.RemoveKeyValue(string groupName, string keyName);

// 指定されたグループのカスタムデータを全て削除します
CustomInformationRegister.RemoveGroup(string groupName);

// 全てのカスタムデータを削除します
CustomInformationRegister.RemoveAll();

登録したカスタムデータの参照

以下のAPIを呼び出すことで、追加済みのカスタムデータを取得できます。

// 指定されたキー名のカスタムデータを取得します
CustomInformationRegister.GetCustomInformationIntValue(string groupName, string keyName);
CustomInformationRegister.GetCustomInformationFloatValue(string groupName, string keyName);
CustomInformationRegister.GetCustomInformationStringValue(string groupName, string keyName);
CustomInformationRegister.GetCustomInformationBoolValue(string groupName, string keyName);
CustomInformationRegister.GetCustomInformationEnumValue(string groupName, string keyName);

// 指定されたグループのカスタムデータを全て取得します
CustomInformationRegister.GetCustomInformationGroup(string groupName);

// 全てのカスタムデータを取得します
CustomInformationRegister.GetCustomInformationAll();

サンプルコード

using System.Collections.Generic;
using UnityEngine;
#if NOA_DEBUGGER
using NoaDebugger;
#endif

public class Example
{
    void ExampleMethod()
    {
#if NOA_DEBUGGER

        // カスタムデータの取得
        int customValue = CustomInformationRegister.GetCustomInformationIntValue(groupName: "SampleGroup", keyName: "SampleKey").Value;

        // グループ単位でカスタムデータを取得
        NoaCustomInformationGroup groupInfo = CustomInformationRegister.GetCustomInformationGroup(groupName: "SampleGroup");

        // 全てのカスタムデータを取得
        List<NoaCustomInformationGroup> allGroups = CustomInformationRegister.GetCustomInformationAll();

        // グループ内の全てのカスタムデータを参照
        foreach (KeyValuePair<string, string> keyValue in groupInfo.KeyValues)
        {
            Debug.Log($"Key:{keyValue.Key} Value:{keyValue.Value}");
        }

        // グループ内のint型のカスタムデータを参照
        foreach (KeyValuePair<string, NoaCustomInformationIntValue> keyValue in groupInfo.IntKeyValues)
        {
            Debug.Log($"Key:{keyValue.Key} Value:{keyValue.Value.Value}");
            keyValue.Value.Value = keyValue.Value.Value + 1; // 値の更新
        }

        // グループ内のbool型のカスタムデータを参照
        foreach (KeyValuePair<string, NoaCustomInformationBoolValue> keyValue in groupInfo.BoolKeyValues)
        {
            Debug.Log($"Key:{keyValue.Key} Value:{keyValue.Value.Value}");
            keyValue.Value.Value = !keyValue.Value.Value; // 値の更新
        }

#endif
    }
}

[Custom]タブ内の表示を更新

カスタムデータを更新した際は、更新ボタンを押下するまで描画の更新は行われません。
すぐに描画の更新を行いたい場合は、RefreshView() を実行してください。

サンプルコード

#if NOA_DEBUGGER
using NoaDebugger;
#endif

public class Example
{
    // カスタムデータの値
    private string sampleValue;

    void ExampleAddMethod()
    {
#if NOA_DEBUGGER
        // カスタムデータにグループとキーバリューを追加
        ...
#endif
    }

    void ExampleUpdateMethod()
    {
#if NOA_DEBUGGER
        // キーバリューで追加済みの値を更新
        sampleValue = "SampleUpdateValue";

        // Customタブの表示を更新
        CustomInformationRegister.RefreshView();
#endif
    }
}