35 lines
No EOL
1.1 KiB
C#
35 lines
No EOL
1.1 KiB
C#
#if UNITY_EDITOR
|
|
using ShiroginSDK.Runtime.Core.Editor.Attributes;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace ShiroginSDK.Editor
|
|
{
|
|
[CustomPropertyDrawer(typeof(SubHeaderAttribute))]
|
|
public class SubHeaderDrawer : DecoratorDrawer
|
|
{
|
|
public override float GetHeight()
|
|
{
|
|
var subHeader = (SubHeaderAttribute)attribute;
|
|
return EditorGUIUtility.singleLineHeight + subHeader.spaceAbove;
|
|
}
|
|
|
|
public override void OnGUI(Rect position)
|
|
{
|
|
var subHeader = (SubHeaderAttribute)attribute;
|
|
|
|
// Adjust vertical offset
|
|
position.y += subHeader.spaceAbove;
|
|
position.height = EditorGUIUtility.singleLineHeight;
|
|
|
|
// Prevent null or empty label text from crashing Unity 6 UIElements backend
|
|
var headerText = subHeader.header ?? string.Empty;
|
|
if (string.IsNullOrWhiteSpace(headerText))
|
|
return;
|
|
|
|
// Draw the label safely
|
|
EditorGUI.LabelField(position, headerText, EditorStyles.boldLabel);
|
|
}
|
|
}
|
|
}
|
|
#endif |