void ShowAddObjectMenu() { GenericMenu genericMenu = new GenericMenu(); for (int c = 0; c < strategy.GetCategories().Length; c++) { AttachCategoryDefinition category = strategy.GetCategories()[c]; // if (category.min == category.max) // continue; if (CanAddForCategory(c)) { genericMenu.AddItem(new GUIContent(category.objectLabel), false, new GenericMenu.MenuFunction2((object cat) => { objectList.Add(null, (int)cat); objectsRL.index = objectList.Count() - 1; }), c); } else { genericMenu.AddDisabledItem(new GUIContent(category.label)); } } genericMenu.ShowAsContext(); Event.current.Use(); }
public void OnInspectorGUI(SerializedProperty requestProp, bool disableAddButton) { // SerializedProperty prop = objectsProp; objectsRL.displayAdd = !disableAddButton && CanAddAttachObjects(); objectsRL.displayRemove = CanRemoveSelectedAttachObject(); EditorGUILayout.Space(); if (strategy) { for (int c = 0; c < strategy.GetCategories().Length; c++) { AttachCategoryDefinition category = strategy.GetCategories()[c]; if (category.max < 0 || GetCountForCategory(c) < category.max) { DoAttachDropArea(c, category.label); } } } objectsRL.DoLayoutList(); if (selectedObject != objectsRL.index) { selectedObject = objectsRL.index; if (selectedObject != -1) { paramsRL = ParamListEditor.CreateReorderableList(serializedObject, objectsProp.GetArrayElementAtIndex(selectedObject) .FindPropertyRelative("_defaultParams._params"), "Default Params for " + GetLabelForAttachObject(selectedObject)); } else { paramsRL = null; } } if (paramsRL == null) { ResetParamsRL(); } if (CanAddAttachObjects() || CanRemoveSelectedAttachObject()) { EditorGUILayout.Space(); } paramsRL.DoLayoutList(); }