//Custom Implementation Here protected virtual bool ValueEqualsTrigger(SerializedProperty property) { bool v_return = false; try { DependentFieldAttribute attr = attribute as DependentFieldAttribute; if (string.IsNullOrEmpty(attr.DependentFieldName)) { return(true); } SerializedProperty v_dependentField = property.serializedObject != null && attr != null?property.serializedObject.FindProperty(GetPrePath(property) + attr.DependentFieldName) : null; //bool v_isEnum = v_dependentField.propertyType == SerializedPropertyType.Enum && attr.ValueToTrigger != null && attr.ValueToTrigger.GetType().IsEnum; object v_dependentFieldValue = v_dependentField.GetFieldValue();// v_isEnum ? v_dependentField.GetSafeEnumPropertyValue(attr.ValueToTrigger.GetType()) : v_dependentField.GetPropertyValue(); if (attr != null) { if ((attr.ValueToTrigger == null && v_dependentFieldValue == null) || (attr.ValueToTrigger != null && attr.ValueToTrigger.Equals(v_dependentFieldValue))) { v_return = true; } //Invert value if we must use not equal comparer if (attr.UseNotEqualComparer) { v_return = !v_return; } } } catch { } return(v_return); }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { DependentFieldAttribute attr = attribute as DependentFieldAttribute; if (attr != null && attr.CheckerFalseDrawOption != CheckerFalseDrawOptionEnum.DontDrawProperty) { return(EditorGUI.GetPropertyHeight(property, label, true)); } else { return(GetDependentFieldValue(property)? EditorGUI.GetPropertyHeight(property, label, true): -2); } }
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { DependentFieldAttribute attr = attribute as DependentFieldAttribute; if (attr != null && attr.DrawOption != DependentDrawOptionEnum.DontDrawFieldWhenNotExpectedValue) { return(EditorGUI.GetPropertyHeight(property, label, true)); } else { return(ValueEqualsTrigger(property) ? EditorGUI.GetPropertyHeight(property, label, true) : -2); } }
protected virtual bool GetDependentFieldValue(SerializedProperty property) { DependentFieldAttribute attr = attribute as DependentFieldAttribute; SerializedProperty v_dependentField = property.serializedObject != null && attr != null?property.serializedObject.FindProperty(GetPrePath(property) + attr.DependentBoolFieldName) : null; bool v_dependentFieldValue = v_dependentField != null && v_dependentField.propertyType == SerializedPropertyType.Boolean? v_dependentField.boolValue : true; if (attr != null && attr.DependenceOption == DependenceOptionEnum.InverseDependence) { v_dependentFieldValue = !v_dependentFieldValue; } return(v_dependentFieldValue); }
protected override void DrawComponent(Rect position, SerializedProperty property, GUIContent label, System.Type p_type) { DependentFieldAttribute attr = attribute as DependentFieldAttribute; if (attr != null) { bool v_dependentFieldValue = ValueEqualsTrigger(property); if (v_dependentFieldValue || attr.DrawOption != DependentDrawOptionEnum.DontDrawFieldWhenNotExpectedValue) { bool v_oldGUIEnabled = GUI.enabled; if (!v_dependentFieldValue && attr.DrawOption == DependentDrawOptionEnum.ReadOnlyFieldWhenNotExpectedValue) { GUI.enabled = false; } DrawComponentAfterDependenceCheck(position, property, label, p_type); GUI.enabled = v_oldGUIEnabled; } } }