1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[Unity] DictionaryをInspectorに表示する

1
Last updated at Posted at 2026-09-03

朗報!

Unity6.6から、Dictionary<>をInspectorに表示することができるようになりました。

image.png

        [SerializeField]
        [DictionaryDisplay(keyLabel="Target", valueLabel="HP", keyColumnFraction=0.7f, layout=DictionaryLayout.TwoColumns)]
        Dictionary<string, int> myDictionary = new Dictionary<string, int>()
        {
            { "Enemy0", 10 },
            { "Enemy1", 500 },
        };
        

Attribute

[DictionaryDisplay]Attributeを使用することで Keyとvalueのラベル等を指定することができます。

DictionaryDisplayAttribute 説明
keyLabel キーのラベル
valueLabel 値のラベル
layout Inspector上でのレイアウト
keyColumnFraction KeyとValueの表示幅比率(左右に表示時のみ)

また、keyColumnFractionを指定することでkeyとvalueの幅比率を変更することができます

layout 機能 表示
TwoColumns 左右に表示(default) image.png
OneColumnWithValueFoldout Keyの下にValueを折りたたんで表示 image.png
DictionaryLayout.OneColumnWithValueVisible Keyの下にValueを表示 image.png

これは便利!

関連:その他の Attributes

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?