32 lines
986 B
C#
32 lines
986 B
C#
|
|
#if UNITY_EDITOR
|
|
namespace Script.EditorScript
|
|
{
|
|
|
|
using UnityEditor;
|
|
|
|
using UnityEngine;
|
|
|
|
[CustomPropertyDrawer(typeof(InspectorEntry))]
|
|
[ExecuteInEditMode]
|
|
public class InspectorEntryDrawer : PropertyDrawer
|
|
{
|
|
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
|
{
|
|
EditorGUI.BeginProperty(position, label, property);
|
|
|
|
// 计算各个字段的位置
|
|
Rect idRect = new Rect(position.x, position.y, position.width / 2, position.height);
|
|
Rect resourceRect = new Rect(position.x + position.width / 2 + 5, position.y, position.width / 2 - 5, position.height);
|
|
|
|
// 绘制字段
|
|
EditorGUI.PropertyField(idRect, property.FindPropertyRelative("PropId"), GUIContent.none);
|
|
EditorGUI.PropertyField(resourceRect, property.FindPropertyRelative("resource"), GUIContent.none);
|
|
|
|
EditorGUI.EndProperty();
|
|
|
|
}
|
|
}
|
|
}
|
|
#endif
|