private PropertyDrawCondition GetPropertyDrawConditionForField(FieldInfo field) { DrawConditionAttribute[] drawConditionAttributes = (DrawConditionAttribute[])field.GetCustomAttributes(typeof(DrawConditionAttribute), true); if (drawConditionAttributes.Length > 0) { PropertyDrawCondition drawCondition = PropertyDrawConditionDatabase.GetDrawConditionForAttribute(drawConditionAttributes[0].GetType()); return(drawCondition); } else { return(null); } }
private void DrawField(FieldInfo field) { // Check if the field has draw conditions PropertyDrawCondition drawCondition = this.GetPropertyDrawConditionForField(field); if (drawCondition != null) { bool canDrawProperty = drawCondition.CanDrawProperty(this.serializedPropertiesByFieldName[field.Name]); if (!canDrawProperty) { return; } } // Check if the field has HideInInspectorAttribute HideInInspector[] hideInInspectorAttributes = (HideInInspector[])field.GetCustomAttributes(typeof(HideInInspector), true); if (hideInInspectorAttributes.Length > 0) { return; } // Draw the field EditorGUI.BeginChangeCheck(); PropertyDrawer drawer = this.GetPropertyDrawerForField(field); if (drawer != null) { drawer.DrawProperty(this.serializedPropertiesByFieldName[field.Name]); } else { EditorGUILayout.PropertyField(this.serializedPropertiesByFieldName[field.Name], true); } if (EditorGUI.EndChangeCheck()) { OnValueChangedAttribute[] onValueChangedAttributes = (OnValueChangedAttribute[])field.GetCustomAttributes(typeof(OnValueChangedAttribute), true); foreach (var onValueChangedAttribute in onValueChangedAttributes) { PropertyMeta meta = PropertyMetaDatabase.GetMetaForAttribute(onValueChangedAttribute.GetType()); if (meta != null) { meta.ApplyPropertyMeta(this.serializedPropertiesByFieldName[field.Name], onValueChangedAttribute); } } } }
protected bool ShouldDrawField(FieldInfo field) { // Check if the field has draw conditions PropertyDrawCondition drawCondition = this.GetPropertyDrawConditionForField(field); if (drawCondition != null) { bool canDrawProperty = drawCondition.CanDrawProperty(this.serializedPropertiesByFieldName[field.Name]); if (!canDrawProperty) { return(false); } } // Check if the field has HideInInspectorAttribute HideInInspector[] hideInInspectorAttributes = (HideInInspector[])field.GetCustomAttributes(typeof(HideInInspector), true); if (hideInInspectorAttributes.Length > 0) { return(false); } return(true); }