| 123456789101112131415161718192021222324252627282930313233 |
- #if UNITY_EDITOR
- using AppUI.View.Component;
- using UnityEditor;
- using UnityEngine;
- namespace AppUI.Editor
- {
- [CustomPropertyDrawer(typeof(SideSlipDeviceGuideEntry))]
- public class SideSlipDeviceGuideEntryPropertyDrawer : PropertyDrawer
- {
- public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
- {
- return EditorGUI.GetPropertyHeight(property, GetEntryLabel(property), true);
- }
- public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
- {
- EditorGUI.PropertyField(position, property, GetEntryLabel(property), true);
- }
- static GUIContent GetEntryLabel(SerializedProperty property)
- {
- SerializedProperty deviceTypeProp = property.FindPropertyRelative("deviceType");
- if (deviceTypeProp == null)
- return new GUIContent(property.displayName);
- var deviceType = (AimDeviceType)deviceTypeProp.intValue;
- string typeName = deviceType.ToString();
- return new GUIContent(typeName, $"Guide entry for {typeName}");
- }
- }
- }
- #endif
|