public static int Popup(GUIContent label, int selectedIndex, GUIContent[] displayedOptions, GUIStyle style, IntChangeHandler change, IntFailureHandler failure = null, IntValidationHandler validate = null, params GUILayoutOption[] options) { EditorGUI.BeginChangeCheck(); selectedIndex = EditorGUILayout.Popup(label, selectedIndex, displayedOptions, style, options); if (EditorGUI.EndChangeCheck()) { IntApplyChangeHandlers(selectedIndex, change, failure, validate); } return(selectedIndex); }
private static void IntApplyChangeHandlers(int value, IntChangeHandler change, IntFailureHandler failure, IntValidationHandler validate) { bool validated = (validate == null) ? true : validate(value); if (validated) { change(value); } else if (!validated && failure != null) { failure(); } }