コガネブログ

平日更新を目標に Unity や C#、Visual Studio などのゲーム開発アレコレを書いていきます

【Unity】エディタ拡張で作成する GUI を見やすくする機能が用意されている「UnityEditorHelper」紹介

はじめに

「UnityEditorHelper」を Unity プロジェクトに導入することで
エディタ拡張で作成する GUI を見やすくする機能を使用できるようになります

紹介(引用)

HighlightBox

f:id:baba_s:20171123202746p:plain

using (new HighlightBox())
{
    EditorGUILayout.Slider("Range property", 5, 0, 10);
    EditorGUILayout.TextField("Sample Field",  GUILayout.Height(150));
    EditorGUILayout.ObjectField("Object Field", null, typeof (Transform), true);
}

using (new HighlightBox(Color.red))
{
    EditorGUILayout.Slider("Range property", 5, 0, 10);
    EditorGUILayout.TextField("Sample Field", GUILayout.Height(150));
    EditorGUILayout.ObjectField("Object Field", null, typeof(Transform), true);
}

EditorBlock

f:id:baba_s:20171123202754p:plain

using (new EditorBlock(EditorBlock.Orientation.Vertical, "Box"))
{
    EditorGUILayout.Slider("Range property", 5, 0, 10);
    EditorGUILayout.TextField("Sample Field", GUILayout.Height(150));
    EditorGUILayout.ObjectField("Object Field", null, typeof(Transform), true);
}

SwitchColor

f:id:baba_s:20171123202804p:plain

using (new SwitchColor(Color.cyan))
{
    EditorGUILayout.Slider("Range property", 5, 0, 10);
}

using (new SwitchColor(Color.green))
{
    EditorGUILayout.TextField("Sample Field", GUILayout.Height(150));
}

EditorGUILayout.ObjectField("Object Field", null, typeof(Transform), true);

IndentBlock

f:id:baba_s:20171123202819p:plain

using (new IndentBlock())
{
    EditorGUILayout.Slider("Range property", 5, 0, 10);
    using (new IndentBlock())
    {
        EditorGUILayout.TextField("Sample Field", GUILayout.Height(150));
        EditorGUILayout.ObjectField("Object Field", null, typeof (Transform), true);
    }
}

FoldableBlock

f:id:baba_s:20171123202827p:plain

using (new FoldableBlock(ref state, "Foldable Block"))
{
    if(state)
    {
        EditorGUILayout.Slider("Range property", 5, 0, 10);
        EditorGUILayout.TextField("Sample Field", GUILayout.Height(150));
        EditorGUILayout.ObjectField("Object Field", null, typeof (Transform), true);
    }
}

関連記事