以下の内容はhttps://baba-s.hatenablog.com/entry/2017/08/04/120000より取得しました。


【Unity】【Odin - Inspector and Serializer】Dictionary の表示を調整する「DictionaryDrawerSettings」属性

目次

「DictionaryDrawerSettings」属性

「DictionaryDrawerSettings」属性を使用すると
Dictionary の表示を調整できます

f:id:baba_s:20170804114726p:plain

using Sirenix.OdinInspector;
using System.Collections.Generic;

public class Example : SerializedMonoBehaviour
{
    [DictionaryDrawerSettings( DisplayMode = DictionaryDisplayOptions.Foldout )]
    public Dictionary<int, string> dict1;

    [DictionaryDrawerSettings( DisplayMode = DictionaryDisplayOptions.CollapsedFoldout )]
    public Dictionary<int, string> dict2;

    [DictionaryDrawerSettings( IsReadOnly = true )]
    public Dictionary<int, string> dict3;

    [DictionaryDrawerSettings( KeyLabel = "ID", ValueLabel = "名前" )]
    public Dictionary<int, string> dict4;
}

使い方

DisplayMode を設定すると、
折りたたんだ状態で表示されるかどうかを設定できます

[DictionaryDrawerSettings( DisplayMode = DictionaryDisplayOptions.Foldout )]
public Dictionary<int, string> dict1;

[DictionaryDrawerSettings( DisplayMode = DictionaryDisplayOptions.CollapsedFoldout )]
public Dictionary<int, string> dict2;

IsReadOnly を設定すると、
キーの追加や削除、変更ができなくなります

[DictionaryDrawerSettings( IsReadOnly = true )]
public Dictionary<int, string> dict3;

KeyLabel や ValueLabel を設定すると、
各ラベルの表記を変更できます

[DictionaryDrawerSettings( KeyLabel = "ID", ValueLabel = "名前" )]
public Dictionary<int, string> dict4;

参考サイト様

Odin Inspector and Serializer | Improve your workflow in Unity




以上の内容はhttps://baba-s.hatenablog.com/entry/2017/08/04/120000より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14