mirror of
https://github.com/codewriter-packages/Tri-Inspector.git
synced 2025-01-23 00:38:21 -05:00
43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using TriInspector.Utilities;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace TriInspector.Elements
|
|
{
|
|
public class TriBoxGroupElement : TriHeaderGroupBaseElement
|
|
{
|
|
private readonly GUIContent _headerLabel;
|
|
|
|
public TriBoxGroupElement(DeclareBoxGroupAttribute attribute)
|
|
{
|
|
_headerLabel = attribute.Title == null
|
|
? GUIContent.none
|
|
: new GUIContent(attribute.Title);
|
|
}
|
|
|
|
protected override float GetHeaderHeight(float width)
|
|
{
|
|
if (string.IsNullOrEmpty(_headerLabel.text))
|
|
{
|
|
return 0f;
|
|
}
|
|
|
|
return base.GetHeaderHeight(width);
|
|
}
|
|
|
|
protected override void DrawHeader(Rect position)
|
|
{
|
|
TriEditorGUI.DrawBox(position, TriEditorStyles.TabOnlyOne);
|
|
|
|
var headerLabelRect = new Rect(position)
|
|
{
|
|
xMin = position.xMin + 6,
|
|
xMax = position.xMax - 6,
|
|
yMin = position.yMin + 2,
|
|
yMax = position.yMax - 2,
|
|
};
|
|
|
|
EditorGUI.LabelField(headerLabelRect, _headerLabel);
|
|
}
|
|
}
|
|
} |