コード例 #1
0
        [EventHandlerAttribute(EventType.MouseDown, -1)] // One of the highest priorities after node selection
        private static void HandleContextClicks(NodeEditorInputInfo inputInfo)
        {
            if (Event.current.button == 1)
            {
                // Handle context clicks on Node and canvas
                if (inputInfo.editorState.focusedNode != null) // Node Context Click
                {
                    if (!NodeEditor.CheckNodeIsSelected(inputInfo.editorState.focusedNode))
                    {
                        inputInfo.editorState.selectedNodes.Clear();
                        inputInfo.editorState.selectedNodes.Add(inputInfo.editorState.focusedNode);
                    }

                    GenericMenu contextMenu = new GenericMenu();
                    FillContextMenu(inputInfo, contextMenu, ContextType.Node);
                    contextMenu.ShowAsContext();
                    Event.current.Use();
                }
                else // Editor Context Click
                {
                    inputInfo.editorState.selectedNodes.Clear();
                    CreateNodesAdvancedDropdown.ShowDropdown(new Rect(inputInfo.inputPos, Vector2.zero));
                    Event.current.Use();
                }
            }
        }
コード例 #2
0
        private static void HandleApplyConnection(NodeEditorInputInfo inputInfo)
        {
            NodeEditorState state = inputInfo.editorState;

            if (inputInfo.inputEvent.button == 0 && state.connectKnob != null)
            {
                if (state.focusedNode != null && state.focusedConnectionKnob != null &&
                    state.focusedConnectionKnob != state.connectKnob)
                {
                    // A connection curve was dragged and released onto a connection knob
                    state.focusedConnectionKnob.TryApplyConnection(state.connectKnob);
                }
                else if (CreateConnection)
                {
                    CreateConnection = false;
                    CreateNodesAdvancedDropdown.ShowDropdown(new Rect(inputInfo.inputPos, Vector2.zero), state.connectKnob);
                }

                inputInfo.inputEvent.Use();
            }

            state.connectKnob = null;
        }