static MemberInfo MemberSelectField(Rect position, Component target, string selected) { var propertyList = target.GetType().GetProperties(UniversalObserver.MemberBindingFlag) .Where(p => TypeReader.Contains(p.PropertyType)) .ToArray(); var fieldList = target.GetType().GetFields(UniversalObserver.MemberBindingFlag) .Where(f => TypeReader.Contains(f.FieldType)) .ToArray(); if (propertyList.Length == 0 && fieldList.Length == 0) { EditorGUI.BeginDisabledGroup(true); EditorGUI.Popup(position, 0, new string[] { "{no observable properties}" }); EditorGUI.EndDisabledGroup(); return(null); } var namelist = propertyList .Select(p => p.Name + " (" + p.PropertyType.Name + ")") .Concat(fieldList.Select(f => f.Name + " (" + f.FieldType.Name + ")")).ToArray(); int selection = 0; if (selected != null) { for (int i = 0; i < propertyList.Length; i++) { if (propertyList[i].Name == selected) { selection = i; break; } } for (int i = 0; i < fieldList.Length; i++) { if (fieldList[i].Name == selected) { selection = i + propertyList.Length; break; } } } var newselection = EditorGUI.Popup(position, selection, namelist); if (newselection < propertyList.Length) { var tgt = propertyList[newselection]; return(new MemberInfo(tgt.Name, tgt.PropertyType, MemberTypes.Property)); } else if (newselection < propertyList.Length + fieldList.Length) { var tgt = fieldList[newselection - propertyList.Length]; return(new MemberInfo(tgt.Name, tgt.FieldType, MemberTypes.Field)); } else { return(null); } }