public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { ValueChangeEvent target = ValueChangeEventID.FindValueChangeEvent(property.serializedObject.targetObject as Component, property.name); float height = EditorGUIUtility.singleLineHeight; if (target != null && mastersEditor != null) { height += mastersEditor.GetHeight() + EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; } return(height); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { ValueChangeEvent target = ValueChangeEventID.FindValueChangeEvent(property.serializedObject.targetObject as Component, property.name); if (target == null) { EditorGUI.LabelField(position, "(" + property.type + ")"); return; } if (changeCheck == true) { changeCheck = false; target.Trigger(); EditorUtility.SetDirty(property.serializedObject.targetObject as Component); } if (target.inspectorHighlight) { highlightProperty = true; highlightStartTime = Time.realtimeSinceStartup; target.inspectorHighlight = false; } if (highlightProperty == true) { HighlightFade(position, property); } Rect controlRect = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label); EditorGUI.BeginProperty(position, label, property); int indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; SerializedProperty valueProperty = property.FindPropertyRelative("value"); SerializedProperty enumNamesProperty = property.FindPropertyRelative("enumNames"); if (valueProperty != null) { ValueGUI(controlRect, valueProperty, enumNamesProperty); } else { TriggerGUI(controlRect); } Rect arrowRect = position; arrowRect.height = EditorGUIUtility.singleLineHeight; arrowRect.width = position.width - controlRect.width; if (target.MasterCount == 0) { target.inspectorUnfold = EditorGUI.Foldout(arrowRect, target.inspectorUnfold, GUIContent.none, true, GUIStyle.none); } else { target.inspectorUnfold = EditorGUI.Foldout(arrowRect, target.inspectorUnfold, GUIContent.none, true); } if (target.inspectorUnfold) { if (mastersEditor == null || mastersEditor.target != target) { mastersEditor = new ValueChangeEventMastersEditor(target); } position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; mastersEditor.OnGUI(position, ref changeCheck); } else if (mastersEditor != null) { mastersEditor = null; } EditorGUI.indentLevel = indent; EditorGUI.EndProperty(); }