コード例 #1
0
        [EventHandlerAttribute(-4)] // Absolute first to call!
        private static void HandleFocussing(NodeEditorInputInfo inputInfo)
        {
            NodeEditorState state = inputInfo.editorState;

            //必须放在这个地方,因为需要处理连线问题,如果不每次刷新就检测,就无法处理
            state.focusedNode = NodeEditor.NodeAtPosition(NodeEditor.ScreenToCanvasSpace(inputInfo.inputPos), out state.focusedConnectionKnob);
        }
コード例 #2
0
                               104)] // Priority over hundred to make it call after the GUI, and before Node dragging (110) and window panning (105)
        private static void HandleGroupDraggingStart(NodeEditorInputInfo inputInfo)
        {
            if (GUIUtility.hotControl > 0)
            {
                return; // GUI has control
            }
            NodeEditorState state = inputInfo.editorState;

            if (inputInfo.inputEvent.button == 0 && state.focusedNode == null && state.dragNode == false)
            {
                // Do not interfere with other dragging stuff
                NodeGroup focusedGroup = GroupAtPositionInput(state, NodeEditor.ScreenToCanvasSpace(inputInfo.inputPos));
                if (focusedGroup != null)
                {
                    // Start dragging the focused group
                    UpdateGroupOrder();
                    Vector2 canvasInputPos = NodeEditor.ScreenToCanvasSpace(inputInfo.inputPos);
                    if (CheckBorderSelection(state, focusedGroup.bodyRect, canvasInputPos, out NodeGroup.resizeDir))
                    {
                        // Resizing
                        state.activeGroup = focusedGroup;
                        // Get start drag position
                        Vector2 startSizePos = Vector2.zero;
                        if ((NodeGroup.resizeDir & BorderSelection.Left) != 0)
                        {
                            startSizePos.x = focusedGroup.rect.xMin;
                        }
                        else if ((NodeGroup.resizeDir & BorderSelection.Right) != 0)
                        {
                            startSizePos.x = focusedGroup.rect.xMax;
                        }
                        if ((NodeGroup.resizeDir & BorderSelection.Top) != 0)
                        {
                            startSizePos.y = focusedGroup.rect.yMin;
                        }
                        else if ((NodeGroup.resizeDir & BorderSelection.Bottom) != 0)
                        {
                            startSizePos.y = focusedGroup.rect.yMax;
                        }
                        // Start the resize drag
                        state.StartDrag("group", inputInfo.inputPos, startSizePos);
                        state.resizeGroup = true;
                        inputInfo.inputEvent.Use();
                    }
                    else if (focusedGroup.headerRect.Contains(canvasInputPos))
                    {
                        // Dragging
                        state.activeGroup = focusedGroup;
                        state.StartDrag("group", inputInfo.inputPos, state.activeGroup.rect.position);
                        state.activeGroup.UpdatePins();
                        inputInfo.inputEvent.Use();
                    }
                }
            }
        }
コード例 #3
0
        private static void DuplicateNode(NodeEditorInputInfo inputInfo)
        {
            NodeEditorState state = inputInfo.editorState;

            if (state.focusedNode != null && state.canvas.CanAddNode(state.focusedNode.GetID))
            {             // Create new node of same type
                Node.Create(state.focusedNode.GetID, NodeEditor.ScreenToCanvasSpace(inputInfo.inputPos), state.canvas, state.connectKnob);
                state.connectKnob = null;
                inputInfo.inputEvent.Use();
            }
        }
        private static void HandleFocussing(NodeEditorInputInfo inputInfo)
        {
            NodeEditorState editorState = inputInfo.editorState;

            editorState.focusedNode = NodeEditor.NodeAtPosition(NodeEditor.ScreenToCanvasSpace(inputInfo.inputPos), out editorState.focusedNodeKnob);
            if ((UnityEngine.Object)unfocusControlsForState == (UnityEngine.Object)editorState && Event.current.type == EventType.Repaint)
            {
                GUIUtility.hotControl      = 0;
                GUIUtility.keyboardControl = 0;
                unfocusControlsForState    = null;
            }
        }
コード例 #5
0
        private static void DuplicateNode(NodeEditorInputInfo inputInfo)
        {
            inputInfo.SetAsCurrentEnvironment();
            NodeEditorState state = inputInfo.editorState;

            if (state.focusedNode != null)
            {             // Create new node of same type
                Node duplicatedNode = Node.Create(state.focusedNode.GetID, NodeEditor.ScreenToCanvasSpace(inputInfo.inputPos), state.connectOutput);
                state.selectedNode  = state.focusedNode = duplicatedNode;
                state.connectOutput = null;
                inputInfo.inputEvent.Use();
            }
        }
コード例 #6
0
        private static void CreateNodeCallback(object infoObj)
        {
            NodeEditorInputInfo callback = infoObj as NodeEditorInputInfo;

            if (callback == null)
            {
                throw new UnityException("Callback Object passed by context is not of type NodeEditorInputInfo!");
            }

            Node.Create(callback.message, NodeEditor.ScreenToCanvasSpace(callback.inputPos), callback.editorState.canvas, callback.editorState.connectKnob);
            callback.editorState.connectKnob = null;
            NodeEditor.RepaintClients();
        }
コード例 #7
0
        private static void DuplicateNode(NodeEditorInputInfo inputInfo)
        {
            inputInfo.SetAsCurrentEnvironment();
            NodeEditorState state = inputInfo.editorState;

            if (state.focusedNode != null && NodeEditor.curNodeCanvas.CanAddNode(state.focusedNode.GetID))
            {             // Create new node of same type
                Node duplicatedNode = Node.CreateCopy(state.focusedNode, NodeEditor.ScreenToCanvasSpace(inputInfo.inputPos), state.connectKnob, false);
                state.selectedNode = state.focusedNode = duplicatedNode;
                state.connectKnob  = null;
                inputInfo.inputEvent.Use();
            }
        }
        private static void DuplicateNode(NodeEditorInputInfo inputInfo)
        {
            inputInfo.SetAsCurrentEnvironment();
            NodeEditorState editorState = inputInfo.editorState;

            if ((UnityEngine.Object)editorState.focusedNode != (UnityEngine.Object)null)
            {
                Node focusedNode = Node.Create(editorState.focusedNode.GetID, NodeEditor.ScreenToCanvasSpace(inputInfo.inputPos), editorState.connectOutput);
                editorState.selectedNode  = (editorState.focusedNode = focusedNode);
                editorState.connectOutput = null;
                inputInfo.inputEvent.Use();
            }
        }
        private static void CreateNodeCallback(object infoObj)
        {
            NodeEditorInputInfo nodeEditorInputInfo = infoObj as NodeEditorInputInfo;

            if (nodeEditorInputInfo == null)
            {
                throw new UnityException("Callback Object passed by context is not of type NodeEditorInputInfo!");
            }
            nodeEditorInputInfo.SetAsCurrentEnvironment();
            Node.Create(nodeEditorInputInfo.message, NodeEditor.ScreenToCanvasSpace(nodeEditorInputInfo.inputPos), nodeEditorInputInfo.editorState.connectOutput);
            nodeEditorInputInfo.editorState.connectOutput = null;
            NodeEditor.RepaintClients();
        }
コード例 #10
0
        [EventHandlerAttribute(-4)]          // Absolute first to call!
        private static void HandleFocussing(NodeEditorInputInfo inputInfo)
        {
            NodeEditorState state = inputInfo.editorState;

            // Choose focused Node
            state.focusedNode = NodeEditor.NodeAtPosition(NodeEditor.ScreenToCanvasSpace(inputInfo.inputPos), out state.focusedConnectionKnob);
            // Perform focus changes in Repaint, which is the only suitable time to do this
            if (unfocusControlsForState == state && Event.current.type == EventType.Repaint)
            {
                GUIUtility.hotControl      = 0;
                GUIUtility.keyboardControl = 0;
                unfocusControlsForState    = null;
            }
        }
コード例 #11
0
        [EventHandlerAttribute(EventType.MouseDown, -1)]          // Before the other context clicks because they won't account for groups
        private static void HandleGroupContextClick(NodeEditorInputInfo inputInfo)
        {
            NodeEditorState state = inputInfo.editorState;

            if (inputInfo.inputEvent.button == 1 && state.focusedNode == null)
            {             // Right-click NOT on a node
                NodeGroup focusedGroup = HeaderAtPosition(state, NodeEditor.ScreenToCanvasSpace(inputInfo.inputPos));
                if (focusedGroup != null)
                {                 // Context click for the group. This is static, not dynamic, because it would be useless
                    GenericMenu context = new GenericMenu();
                    context.AddItem(new GUIContent("Delete"), false, () => { NodeEditor.curNodeCanvas = state.canvas; focusedGroup.Delete(); });
                    context.ShowAsContext();
                    inputInfo.inputEvent.Use();
                }
            }
        }
コード例 #12
0
        [EventHandlerAttribute(EventType.MouseDown, 20)] // Priority over hundred to make it call after the GUI
        private static void HandleWindowSelectionStart(NodeEditorInputInfo inputInfo)
        {
            if (GUIUtility.hotControl > 0)
            {
                return; // GUI has control
            }
            NodeEditorState state = inputInfo.editorState;

            if (inputInfo.inputEvent.button == 0 && state.focusedNode == null &&
                NodeGroup.HeaderAtPosition(state, NodeEditor.ScreenToCanvasSpace(inputInfo.inputPos)) == null)
            {
                // Left clicked on the empty canvas -> Start the selection process
                state.boxSelecting = true;
                startSelectionPos  = inputInfo.inputPos;
            }
        }
コード例 #13
0
 private static void CreateGroup(NodeEditorInputInfo info)
 {
     NodeEditor.curEditorState = info.editorState;
     NodeEditor.curNodeCanvas  = info.editorState.canvas;
     new NodeGroup("Group", NodeEditor.ScreenToCanvasSpace(info.inputPos));
 }
コード例 #14
0
 private static void CreateGroup(NodeEditorInputInfo info)
 {
     info.SetAsCurrentEnvironment();
     new NodeGroup("Group", NodeEditor.ScreenToCanvasSpace(info.inputPos));
 }