101 lines
2.7 KiB
C#
101 lines
2.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEditor;
|
|
using BF;
|
|
|
|
namespace BFEditor
|
|
{
|
|
[CustomEditor(typeof(BFHorizontalOrVerticalLayout))]
|
|
public class BFHorVInspector : Editor
|
|
{
|
|
BFHorizontalOrVerticalLayout layout;
|
|
private bool isDirty = false;
|
|
private float tmpFloat = 0.0f;
|
|
private TextAnchor tmpTextAnchor = TextAnchor.UpperLeft;
|
|
private bool tmpBool = false;
|
|
|
|
void OnEnable()
|
|
{
|
|
layout = target as BFHorizontalOrVerticalLayout;
|
|
}
|
|
|
|
public override void OnInspectorGUI()
|
|
{
|
|
isDirty = false;
|
|
EditorGUILayout.BeginVertical();
|
|
|
|
tmpFloat = EditorGUILayout.FloatField("Left", layout.Left);
|
|
if (layout.Left != tmpFloat)
|
|
{
|
|
isDirty = true;
|
|
layout.Left = tmpFloat;
|
|
}
|
|
tmpFloat = EditorGUILayout.FloatField("Right", layout.Right);
|
|
if (layout.Right != tmpFloat)
|
|
{
|
|
isDirty = true;
|
|
layout.Right = tmpFloat;
|
|
}
|
|
tmpFloat = EditorGUILayout.FloatField("Top", layout.Top);
|
|
if (layout.Top != tmpFloat)
|
|
{
|
|
isDirty = true;
|
|
layout.Top = tmpFloat;
|
|
}
|
|
tmpFloat = EditorGUILayout.FloatField("Bottom", layout.Bottom);
|
|
if (layout.Bottom != tmpFloat)
|
|
{
|
|
isDirty = true;
|
|
layout.Bottom = tmpFloat;
|
|
}
|
|
|
|
tmpTextAnchor = (TextAnchor)EditorGUILayout.Popup("Child Alignment", (int)layout.ChildAlignment, new string[]
|
|
{
|
|
"UpperLeft",
|
|
"UpperCenter",
|
|
"UpperRight",
|
|
"MiddleLeft",
|
|
"MiddleCenter",
|
|
"MiddleRight",
|
|
"LowerLeft",
|
|
"LowerCenter",
|
|
"LowerRight",
|
|
});
|
|
|
|
if (layout.ChildAlignment != tmpTextAnchor)
|
|
{
|
|
isDirty = true;
|
|
layout.ChildAlignment = tmpTextAnchor;
|
|
}
|
|
|
|
tmpFloat = EditorGUILayout.FloatField("Spaceing", layout.Spaceing);
|
|
if (layout.Spaceing != tmpFloat)
|
|
{
|
|
isDirty = true;
|
|
layout.Spaceing = tmpFloat;
|
|
}
|
|
|
|
tmpBool = EditorGUILayout.Toggle("VerticalOrHorizontal", layout.VerticalOrHorizontal);
|
|
if (layout.VerticalOrHorizontal != tmpBool)
|
|
{
|
|
isDirty = true;
|
|
layout.VerticalOrHorizontal = tmpBool;
|
|
}
|
|
|
|
if (GUILayout.Button("孩子变化的时候手动刷新"))
|
|
{
|
|
layout.RefreshLayout();
|
|
}
|
|
|
|
if (isDirty)
|
|
{
|
|
EditorUtility.SetDirty(target);
|
|
AssetDatabase.SaveAssets();
|
|
}
|
|
|
|
EditorGUILayout.EndVertical();
|
|
}
|
|
}
|
|
}
|