Files
MuHua-Core/Packages/Tools/Editor/CustomLabelDrawer.cs
T
MuHua-123 5374616980 1
2025-06-17 10:53:45 +08:00

24 lines
772 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using MuHua;
namespace MuHuaEditor {
/// <summary>
/// 定义对带有 `CustomLabelAttribute` 特性的字段的面板内容的绘制行为。
/// </summary>
[CustomPropertyDrawer(typeof(CustomLabelAttribute))]
public class CustomLabelDrawer : PropertyDrawer {
private GUIContent _label = null;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
if (_label == null) {
string name = (attribute as CustomLabelAttribute).name;
_label = new GUIContent(name);
}
EditorGUI.PropertyField(position, property, _label);
}
}
}