void DoProperty(SerializedParameterOverride property, bool overrideState, GUIContent title) { // Check for DisplayNameAttribute first var displayNameAttr = property.GetAttribute <DisplayNameAttribute>(); if (displayNameAttr != null) { title.text = displayNameAttr.displayName; } // Add tooltip if it's missing and an attribute is available if (string.IsNullOrEmpty(title.tooltip)) { var tooltipAttr = property.GetAttribute <TooltipAttribute>(); if (tooltipAttr != null) { title.tooltip = tooltipAttr.tooltip; } } using (new EditorGUI.DisabledScope(!overrideState)) { // Look for a compatible attribute decorator and break as soon as we find one AttributeDecorator decorator = null; Attribute attribute = null; foreach (var attr in property.attributes) { decorator = EditorUtilities.GetDecorator(attr.GetType()); attribute = attr; if (decorator != null) { break; } } if (decorator != null) { if (decorator.OnGUI(property.value, overrideState, title, attribute)) { return; } } EditorGUILayout.PropertyField(property.value, title); } }
protected void PropertyField(SerializedParameterOverride property, GUIContent title) { // Check for DisplayNameAttribute first var displayNameAttr = property.GetAttribute <DisplayNameAttribute>(); if (displayNameAttr != null) { title.text = displayNameAttr.displayName; } // Add tooltip if it's missing and an attribute is available if (string.IsNullOrEmpty(title.tooltip)) { var tooltipAttr = property.GetAttribute <TooltipAttribute>(); if (tooltipAttr != null) { title.tooltip = tooltipAttr.tooltip; } } // Look for a compatible attribute decorator and break as soon as we find one AttributeDecorator decorator = null; Attribute attribute = null; foreach (var attr in property.attributes) { decorator = EditorUtilities.GetDecorator(attr.GetType()); attribute = attr; if (decorator != null) { break; } } bool invalidProp = false; if (decorator != null && !decorator.IsAutoProperty()) { if (decorator.OnGUI(property.value, property.overrideState, title, attribute)) { return; } // Attribute is invalid for the specified property; use default unity field instead invalidProp = true; } using (new EditorGUILayout.HorizontalScope()) { // Override checkbox var overrideRect = GUILayoutUtility.GetRect(17f, 17f, GUILayout.ExpandWidth(false)); overrideRect.yMin += 4f; EditorUtilities.DrawOverrideCheckbox(overrideRect, property.overrideState); // Property using (new EditorGUI.DisabledScope(!property.overrideState.boolValue)) { if (decorator != null && !invalidProp) { if (decorator.OnGUI(property.value, property.overrideState, title, attribute)) { return; } } // Default unity field EditorGUILayout.PropertyField(property.value, title); } } }