private void DrawField(FieldInfo field) { EditorGUI.BeginChangeCheck(); PropertyDrawer drawer = this.GetPropertyDrawerForField(field); if (drawer != null) { drawer.DrawProperty(this.serializedPropertiesByFieldName[field.Name]); } else { EditorDrawUtility.DrawPropertyField(this.serializedPropertiesByFieldName[field.Name]); } 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); } } } }
private void ApplyFieldMeta(FieldInfo field) { // Apply custom meta attributes MetaAttribute[] metaAttributes = field .GetCustomAttributes(typeof(MetaAttribute), true) .Where(attr => attr.GetType() != typeof(OnValueChangedAttribute)) .Select(obj => obj as MetaAttribute) .ToArray(); Array.Sort(metaAttributes, (x, y) => { return(x.Order - y.Order); }); foreach (var metaAttribute in metaAttributes) { PropertyMeta meta = PropertyMetaDatabase.GetMetaForAttribute(metaAttribute.GetType()); if (meta != null) { meta.ApplyPropertyMeta(this.serializedPropertiesByFieldName[field.Name], metaAttribute); } } }