#if UNITY_EDITOR using AppUI.View.Component; using UnityEditor; using UnityEngine; namespace AppUI.Editor { [CustomPropertyDrawer(typeof(SideSlipGuideStepContent))] public class SideSlipGuideStepContentPropertyDrawer : PropertyDrawer { public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { if (!property.isExpanded) return EditorGUIUtility.singleLineHeight; float height = EditorGUIUtility.singleLineHeight; height += GetToggleBlockHeight(property, "useImage", "image"); height += GetToggleBlockHeight(property, "useDescription", "description"); height += GetToggleBlockHeight(property, "useDescriptionKey", "descriptionKey"); height += GetToggleBlockHeight(property, "useDeviceVisualRoot", "deviceVisualRoot"); return height; } static float GetToggleBlockHeight(SerializedProperty property, string toggleName, string fieldName) { float height = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; SerializedProperty toggle = property.FindPropertyRelative(toggleName); if (toggle != null && toggle.boolValue) { SerializedProperty field = property.FindPropertyRelative(fieldName); if (field != null) height += EditorGUI.GetPropertyHeight(field, true) + EditorGUIUtility.standardVerticalSpacing; } return height; } public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); Rect rect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight); property.isExpanded = EditorGUI.Foldout(rect, property.isExpanded, label, true); if (!property.isExpanded) { EditorGUI.EndProperty(); return; } EditorGUI.indentLevel++; rect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; rect = DrawToggleField(rect, property, "useImage", "image", "Image"); rect = DrawToggleField(rect, property, "useDescription", "description", "Description"); rect = DrawToggleField(rect, property, "useDescriptionKey", "descriptionKey", "Description Key"); DrawToggleField(rect, property, "useDeviceVisualRoot", "deviceVisualRoot", "Device Visual Root"); EditorGUI.indentLevel--; EditorGUI.EndProperty(); } static Rect DrawToggleField( Rect rect, SerializedProperty property, string toggleName, string fieldName, string label) { SerializedProperty toggle = property.FindPropertyRelative(toggleName); SerializedProperty field = property.FindPropertyRelative(fieldName); float lineHeight = EditorGUIUtility.singleLineHeight; Rect toggleRect = new Rect(rect.x, rect.y, rect.width, lineHeight); EditorGUI.PropertyField(toggleRect, toggle, new GUIContent(label)); rect.y += lineHeight + EditorGUIUtility.standardVerticalSpacing; if (toggle.boolValue && field != null) { float fieldHeight = EditorGUI.GetPropertyHeight(field, true); Rect fieldRect = new Rect(rect.x, rect.y, rect.width, fieldHeight); EditorGUI.PropertyField(fieldRect, field, GUIContent.none, true); rect.y += fieldHeight + EditorGUIUtility.standardVerticalSpacing; } return rect; } } } #endif