/// <summary> /// Draws the dropdown for selecting a method from bindableViewModelMethods /// </summary> private void ShowMethodMenu(EventBinding targetScript, MethodInfo[] bindableMethods) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("View-model method"); var dropdownPosition = GUILayoutUtility.GetLastRect(); dropdownPosition.x += dropdownPosition.width; if (GUILayout.Button(new GUIContent(targetScript.viewModelMethodName), EditorStyles.popup)) { InspectorUtils.ShowMenu <MethodInfo>( method => method.ReflectedType + "/" + method.Name, method => true, method => method.ReflectedType.Name + "." + method.Name == targetScript.viewModelMethodName, method => UpdateProperty( updatedValue => targetScript.viewModelMethodName = updatedValue, targetScript.viewModelMethodName, method.ReflectedType.Name + "." + method.Name ), bindableMethods, dropdownPosition ); } EditorGUILayout.EndHorizontal(); }
/// <summary> /// Display a popup menu for selecting a property from a view-model. /// </summary> protected void ShowViewModelPropertyMenu( string label, AbstractMemberBinding target, PropertyInfo[] bindableProperties, Action <string> propertyValueSetter, string curPropertyValue, Func <PropertyInfo, bool> menuEnabled ) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(label); var dropdownPosition = GUILayoutUtility.GetLastRect(); dropdownPosition.x += dropdownPosition.width; if (GUILayout.Button(new GUIContent(curPropertyValue), EditorStyles.popup)) { InspectorUtils.ShowMenu <PropertyInfo>( property => property.ReflectedType + "/" + property.Name + " : " + property.PropertyType.Name, menuEnabled, property => property.ReflectedType.Name + "." + property.Name == curPropertyValue, property => UpdateProperty( propertyValueSetter, curPropertyValue, property.ReflectedType.Name + "." + property.Name ), bindableProperties, dropdownPosition ); } EditorGUILayout.EndHorizontal(); }