55 lines
1.1 KiB
C#
55 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Reflection;
|
|
|
|
using UnityEditor;
|
|
|
|
using UnityEngine;
|
|
|
|
using static UnityEngine.GraphicsBuffer;
|
|
|
|
namespace XericLibrary.Runtime.CustomDrawer
|
|
{
|
|
public class GroupAttribute : PropertyAttribute
|
|
{
|
|
public string group;
|
|
|
|
public GroupAttribute(string groupName)
|
|
{
|
|
group = groupName;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// ʹÓ÷Ö×鹦ÄܵÄʾÀý
|
|
/// </summary>
|
|
//[CustomEditor(typeof(GroupAttribute))]
|
|
public class GroupExampleEditor : Editor
|
|
{
|
|
public override void OnInspectorGUI()
|
|
{
|
|
base.OnInspectorGUI();
|
|
|
|
//ShowGroupInspector(target);
|
|
}
|
|
|
|
public static void ShowGroupInspector(Editor editor, object target)
|
|
{
|
|
// Iterate through the fields
|
|
foreach(var field in target.GetType().GetFields())
|
|
{
|
|
var groupAttribute = field.GetCustomAttribute<GroupAttribute>();
|
|
if(groupAttribute != null)
|
|
{
|
|
EditorGUILayout.Space();
|
|
EditorGUILayout.LabelField(groupAttribute.group, EditorStyles.boldLabel);
|
|
}
|
|
|
|
EditorGUILayout.PropertyField(editor.serializedObject.FindProperty(field.Name), true);
|
|
}
|
|
|
|
editor.serializedObject.ApplyModifiedProperties();
|
|
}
|
|
}
|
|
} |