Skip to content

Instantly share code, notes, and snippets.

@gok11
Created October 22, 2016 15:50
Show Gist options
  • Select an option

  • Save gok11/e4f6be1f3ee26b62111d2a6f12151bdc to your computer and use it in GitHub Desktop.

Select an option

Save gok11/e4f6be1f3ee26b62111d2a6f12151bdc to your computer and use it in GitHub Desktop.
エディタ拡張で仕切り線を描く ref: http://qiita.com/Gok/items/96e8747269bf4a2a9cc5
using UnityEngine;
using UnityEditor;
public class EditorGUILayoutEx {
/// <summary>
/// インデントレベル設定を考慮した仕切り線.
/// </summary>
/// <param name="useIndentLevel">インデントレベルを考慮するか.</param>
public static void Separator(bool useIndentLevel = false)
{
EditorGUILayout.BeginHorizontal();
if (useIndentLevel)
{
GUILayout.Space(EditorGUI.indentLevel * 15);
}
GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));
EditorGUILayout.EndHorizontal();
}
/// <summary>
/// インデントレベルを設定する仕切り線.
/// </summary>
/// <param name="indentLevel">インデントレベル</param>
public static void Separator(int indentLevel)
{
EditorGUILayout.BeginHorizontal();
GUILayout.Space(indentLevel * 15);
GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));
EditorGUILayout.EndHorizontal();
}
}
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(SampleClass))]
public class SampleClassInspector : Editor {
public override void OnInspectorGUI()
{
DrawDefaultInspector();
EditorGUI.indentLevel = 1;
GUILayout.Label("----- 以下インデントレベル1 -----");
EditorGUILayoutEx.Separator();
EditorGUILayout.PrefixLabel("↑ レベル無視インデント0");
EditorGUILayoutEx.Separator(true);
EditorGUILayout.PrefixLabel("↑ レベルに従う");
GUILayout.Space(10);
EditorGUI.indentLevel = 0;
GUILayout.Label("----- 以下インデントレベル0 -----");
EditorGUILayoutEx.Separator(2);
EditorGUILayout.PrefixLabel("↑ レベル無視インデント2");
EditorGUILayoutEx.Separator(3);
EditorGUILayout.PrefixLabel("↑ レベル無視インデント3");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment