private void AddItemToMethodHandlers(ComponentBindingViewHandler viewHandler, SerializedProperty componentActionsProperty, int index) { ComponentBindingMethodHandler item = new ComponentBindingMethodHandler(viewHandler.bindingGenericType, componentActionsProperty.GetArrayElementAtIndex(index)); item.SetupMethods(); _methodHandlers.Add(item); }
private void DrawListElement(Rect rect, int index, bool isActive, bool isFocused) { if (index >= _methodHandlers.Count) { return; } ComponentBindingMethodHandler methodHandler = _methodHandlers[index]; float columnX = rect.x + 2F; float columnWidth = rect.width * .2F; float paddingRight = 18F; Rect movingRect = rect; movingRect.x = columnX; movingRect.y += 2F; movingRect.width = columnWidth; movingRect.height = _propertyHeight; EditorGUI.LabelField(movingRect, "Event name: ", EditorStyles.boldLabel); movingRect.x += columnWidth; movingRect.y += 2F; movingRect.width = rect.width - movingRect.width - paddingRight; int selectedActionEventIndex = methodHandler.selectedActionEventNameIndex; string[] actionEventsNames = methodHandler.actionEventsNames; int newSelection = EditorGUI.Popup(movingRect, selectedActionEventIndex, actionEventsNames, _popupStyle); if (newSelection != selectedActionEventIndex) { methodHandler.selectedActionEventNameIndex = newSelection; methodHandler.SetEventNameFieldValue(); methodHandler.SetupMethods(); } movingRect.x = columnX; movingRect.y += _propertyHeight - 2F; movingRect.width = columnWidth; movingRect.height = _propertyHeight; EditorGUI.LabelField(movingRect, "Target: ", EditorStyles.boldLabel); EditorGUI.BeginChangeCheck(); { movingRect.x += movingRect.width; movingRect.width = rect.width - movingRect.width - paddingRight; movingRect.height = _propertyHeight; methodHandler.methodTargetProperty.objectReferenceValue = EditorGUI.ObjectField(movingRect, methodHandler.methodTargetProperty.objectReferenceValue, typeof(MonoBehaviour), true); } if (EditorGUI.EndChangeCheck() && methodHandler.methodTargetProperty.serializedObject.ApplyModifiedProperties()) { methodHandler.SetupMethods(); methodHandler.SetMethodNameFieldValue(_viewHandler.viewProperty, false); } movingRect.y += _propertyHeight; movingRect.x = columnX; movingRect.width = columnWidth; EditorGUI.LabelField(movingRect, "Bound to: ", EditorStyles.boldLabel); movingRect.y += 4F; movingRect.x += movingRect.width; movingRect.width = rect.width - movingRect.width - paddingRight; int selectedMethodIndex = methodHandler.selectedMethodIndex; string[] allMethodsSignatures = methodHandler.allMethodsSignatures; newSelection = EditorGUI.Popup( movingRect, selectedMethodIndex, allMethodsSignatures, _popupStyle); if (newSelection != selectedMethodIndex) { methodHandler.selectedMethodIndex = newSelection; methodHandler.SetMethodNameFieldValue(_viewHandler.viewProperty); } movingRect.x = rect.width + 38F; movingRect.y = rect.y + 2F; movingRect.width = 18F; movingRect.height = _elementHeight * .9F; if (GUI.Button(movingRect, "-")) { _reorderableList.index = index; RemoveListElement(_reorderableList); } }