public sealed override void OnGUI(Rect rect, SerializedProperty property, GUIContent label) { // Check if visible bool visible = PropertyUtility.IsVisible(property); if (!visible) { return; } // Validate ValidatorAttribute[] validatorAttributes = PropertyUtility.GetAttributes <ValidatorAttribute>(property); foreach (var validatorAttribute in validatorAttributes) { validatorAttribute.GetValidator().ValidateProperty(property); } // Check if enabled and draw EditorGUI.BeginChangeCheck(); bool enabled = PropertyUtility.IsEnabled(property); GUI.enabled = enabled; OnGUI_Internal(rect, property, new GUIContent(PropertyUtility.GetLabel(property))); GUI.enabled = true; // Call OnValueChanged callbacks if (EditorGUI.EndChangeCheck()) { PropertyUtility.CallOnValueChangedCallbacks(property); } }
public static void PropertyField_Layout(SerializedProperty property, bool includeChildren) { SpecialCaseDrawerAttribute specialCaseAttribute = PropertyUtility.GetAttribute <SpecialCaseDrawerAttribute>(property); if (specialCaseAttribute != null) { specialCaseAttribute.GetDrawer().OnGUI(property); } else { GUIContent label = new GUIContent(PropertyUtility.GetLabel(property)); bool anyDrawerAttribute = PropertyUtility.GetAttributes <DrawerAttribute>(property).Any(); var style = new GUIStyle(); style.normal.textColor = Color.white; style.fontStyle = FontStyle.Bold; style.fontSize = 13; style.contentOffset = new Vector2(10, 0); if (!anyDrawerAttribute) { // Drawer attributes check for visibility, enableability and validator themselves, // so if a property doesn't have a DrawerAttribute we need to check for these explicitly // Check if visible bool visible = PropertyUtility.IsVisible(property); if (!visible) { return; } // Validate ValidatorAttribute[] validatorAttributes = PropertyUtility.GetAttributes <ValidatorAttribute>(property); foreach (var validatorAttribute in validatorAttributes) { validatorAttribute.GetValidator().ValidateProperty(property); } // Check if enabled and draw EditorGUI.BeginChangeCheck(); bool enabled = PropertyUtility.IsEnabled(property); GUI.enabled = enabled; //EditorGUILayout.BeginHorizontal(); //EditorGUILayout.LabelField(property.name, style , GUILayout.MinWidth(152)); EditorGUILayout.PropertyField(property, label, includeChildren); //EditorGUILayout.EndHorizontal(); GUI.enabled = true; // Call OnValueChanged callbacks if (EditorGUI.EndChangeCheck()) { PropertyUtility.CallOnValueChangedCallbacks(property); } } else { // We don't need to check for enableIfAttribute //EditorGUILayout.BeginHorizontal(); //EditorGUILayout.LabelField(property.name, style , GUILayout.MinWidth(152)); EditorGUILayout.PropertyField(property, label, includeChildren); //EditorGUILayout.EndHorizontal(); } } }