private float DrawObjectDropDown(object obj, Rect valuePosition, SerializedProperty sourceTypeProperty, SerializedProperty sourceObjectMemberNameProp, SerializedProperty sourceObjectMemberIndexProp) { List <GUIContent> memberLabels = new List <GUIContent>(); List <MemeberData> memeberInfo = new List <MemeberData>(); int index = 0; //If the object itself is an IValueSource<T> then it can be selected if (SystemUtils.IsTypeOf(typeof(IValueSource <T>), obj.GetType())) { memberLabels.Add(new GUIContent(".this")); memeberInfo.Add(new MemeberData(DynamicValue <T> .eSourceType.SourceObject, null, -1)); if (sourceObjectMemberIndexProp.intValue == -1 && string.IsNullOrEmpty(sourceObjectMemberNameProp.stringValue)) { index = 0; } } //If the object is a dynamic value source container then add its value sources to the list if (SystemUtils.IsTypeOf(typeof(IValueSourceContainer), obj.GetType())) { IValueSourceContainer valueSourceContainer = (IValueSourceContainer)obj; for (int i = 0; i < valueSourceContainer.GetNumberOfValueSource(); i++) { if (SystemUtils.IsTypeOf(typeof(IValueSource <T>), valueSourceContainer.GetValueSource(i).GetType())) { //Ideally be able to get value source name as well? just for editor? memberLabels.Add(new GUIContent(valueSourceContainer.GetValueSourceName(i).ToString())); memeberInfo.Add(new MemeberData(DynamicValue <T> .eSourceType.SourceDynamicMember, null, i)); if (sourceObjectMemberIndexProp.intValue == i) { index = memeberInfo.Count - 1; } } } } //Finally add all public fields that are of type IValueSource<T> FieldInfo[] fields = DynamicValue <T> .GetDynamicValueFields(obj); foreach (FieldInfo field in fields) { memberLabels.Add(new GUIContent("." + field.Name)); memeberInfo.Add(new MemeberData(DynamicValue <T> .eSourceType.SourceMember, field, -1)); if (sourceObjectMemberNameProp.stringValue == field.Name) { index = memeberInfo.Count - 1; } } //Warn if there are no valid options for the object if (memeberInfo.Count == 0) { EditorGUI.LabelField(valuePosition, new GUIContent("Component Property"), new GUIContent("No public IValueSource<" + SystemUtils.GetTypeName(typeof(T)) + ">" + " members!")); } else { bool valueChanged = index != sourceTypeProperty.intValue; EditorGUI.BeginChangeCheck(); index = EditorGUI.Popup(valuePosition, new GUIContent("Component Property"), index, memberLabels.ToArray()); valueChanged |= EditorGUI.EndChangeCheck(); if (valueChanged) { sourceTypeProperty.intValue = Convert.ToInt32(memeberInfo[index]._sourceType); sourceObjectMemberNameProp.stringValue = memeberInfo[index]._fieldInfo != null ? memeberInfo[index]._fieldInfo.Name : null; sourceObjectMemberIndexProp.intValue = memeberInfo[index]._index; } } return(EditorGUIUtility.singleLineHeight); }