using UnityEditor; using UnityEngine; namespace TriInspector.Drawers { public abstract class BuiltinDrawerBase : TriValueDrawer { public sealed override TriElement CreateElement(TriValue propertyValue, TriElement next) { if (propertyValue.Property.TryGetSerializedProperty(out _)) { return next; } return base.CreateElement(propertyValue, next); } public virtual int CompactModeLines => 1; public virtual int WideModeLines => 1; public sealed override float GetHeight(float width, TriValue propertyValue, TriElement next) { var lineHeight = EditorGUIUtility.singleLineHeight; var lines = EditorGUIUtility.wideMode ? WideModeLines : CompactModeLines; return lineHeight * lines; } public sealed override void OnGUI(Rect position, TriValue propertyValue, TriElement next) { var value = propertyValue.SmartValue; EditorGUI.BeginChangeCheck(); value = OnValueGUI(position, propertyValue.Property.DisplayNameContent, value); if (EditorGUI.EndChangeCheck()) { propertyValue.SmartValue = value; } } protected abstract T OnValueGUI(Rect position, GUIContent label, T value); } }