2022-01-10 03:12:44 -05:00
|
|
|
|
using TriInspector.Utilities;
|
|
|
|
|
using UnityEditor;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace TriInspector.Elements
|
|
|
|
|
{
|
2022-01-21 06:21:57 -05:00
|
|
|
|
public class TriBoxGroupElement : TriHeaderGroupBaseElement
|
2022-01-10 03:12:44 -05:00
|
|
|
|
{
|
|
|
|
|
private readonly GUIContent _headerLabel;
|
|
|
|
|
|
|
|
|
|
public TriBoxGroupElement(DeclareBoxGroupAttribute attribute)
|
|
|
|
|
{
|
|
|
|
|
_headerLabel = attribute.Title == null
|
|
|
|
|
? GUIContent.none
|
|
|
|
|
: new GUIContent(attribute.Title);
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-21 06:21:57 -05:00
|
|
|
|
protected override float GetHeaderHeight(float width)
|
2022-01-10 03:12:44 -05:00
|
|
|
|
{
|
2022-01-21 06:21:57 -05:00
|
|
|
|
if (string.IsNullOrEmpty(_headerLabel.text))
|
2022-01-10 03:12:44 -05:00
|
|
|
|
{
|
2022-01-21 06:21:57 -05:00
|
|
|
|
return 0f;
|
2022-01-10 03:12:44 -05:00
|
|
|
|
}
|
|
|
|
|
|
2022-01-21 06:21:57 -05:00
|
|
|
|
return base.GetHeaderHeight(width);
|
2022-01-10 03:12:44 -05:00
|
|
|
|
}
|
|
|
|
|
|
2022-01-21 06:21:57 -05:00
|
|
|
|
protected override void DrawHeader(Rect position)
|
2022-01-10 03:12:44 -05:00
|
|
|
|
{
|
2022-01-30 10:48:54 -05:00
|
|
|
|
TriEditorGUI.DrawBox(position, TriEditorStyles.TabOnlyOne);
|
2022-01-10 03:12:44 -05:00
|
|
|
|
|
2022-01-21 06:21:57 -05:00
|
|
|
|
var headerLabelRect = new Rect(position)
|
2022-01-10 03:12:44 -05:00
|
|
|
|
{
|
2022-01-21 06:21:57 -05:00
|
|
|
|
xMin = position.xMin + 6,
|
|
|
|
|
xMax = position.xMax - 6,
|
|
|
|
|
yMin = position.yMin + 2,
|
|
|
|
|
yMax = position.yMax - 2,
|
|
|
|
|
};
|
2022-01-10 03:12:44 -05:00
|
|
|
|
|
2022-01-21 06:21:57 -05:00
|
|
|
|
EditorGUI.LabelField(headerLabelRect, _headerLabel);
|
2022-01-10 03:12:44 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|