コード例 #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
        [EventHandlerAttribute(EventType.MouseDown, -2)] // Absolute second to call!
        private static void HandleSelecting(NodeEditorInputInfo inputInfo)
        {
            ResetHotControlId();

            NodeEditorState state = inputInfo.editorState;

            if (inputInfo.inputEvent.button == 0 && state.focusedNode != null)
            {
                // Select focussed Node
                if (!NodeEditor.CheckNodeIsSelected(state.focusedNode))
                {
                    state.selectedNodes.Clear();
                    state.selectedNodes.Add(state.focusedNode);
                }
            }

            if (state.selectedNodes.Count > 0 && state.focusedNode != null)
            {
                UnityEditor.Selection.activeObject = state.selectedNodes[0];
            }
            else if (state.focusedNode == null)
            {
                state.selectedNodes.Clear();
                UnityEditor.Selection.activeObject = state.canvas;
            }
        }
コード例 #3
0
        [EventHandlerAttribute(EventType.MouseDown, -2)] // Absolute second to call!
        private static void HandleSelecting(NodeEditorInputInfo inputInfo)
        {
            NodeEditorState state = inputInfo.editorState;

            if (inputInfo.inputEvent.button == 0 && state.focusedNode != null)
            {
                // Select focussed Node
                unfocusControlsForState = state;
                if (!NodeEditor.CheckNodeIsSelected(state.focusedNode))
                {
                    state.selectedNodes.Clear();
                    state.selectedNodes.Add(state.focusedNode);
                }

                NodeEditor.RepaintClients();
            }
#if UNITY_EDITOR
            if (state.selectedNodes.Count > 0 && state.focusedNode != null)
            {
                UnityEditor.Selection.activeObject = state.selectedNodes[0];
            }
            else if (state.focusedNode == null)
            {
                state.selectedNodes.Clear();
                UnityEditor.Selection.activeObject = state.canvas;
            }
#endif
        }
コード例 #4
0
ファイル: Node.cs プロジェクト: mengtest/ET_NKGMobaBasedOnET
        /// <summary>
        /// Draws the node frame and calls NodeGUI. Can be overridden to customize drawing.
        /// </summary>
        protected internal virtual void DrawNode()
        {
            // Create a rect that is adjusted to the editor zoom and pixel perfect
            Rect    nodeRect = rect;
            Vector2 pos      = NodeEditor.curEditorState.zoomPanAdjust + NodeEditor.curEditorState.panOffset;

            nodeRect.position = new Vector2((int)(nodeRect.x + pos.x), (int)(nodeRect.y + pos.y));

            GUIStyle targetNodeBoxStyle =
                NodeEditor.CheckNodeIsSelected(this)
                            ? NodeEditorGUI.nodeBox_HighLight
                            : NodeEditorGUI.nodeBox;

            GUI.color = backgroundColor;
            GUI.Box(nodeRect, GUIContent.none, targetNodeBoxStyle);
            contentOffset = new Vector2(0, 20);

            // Create a headerRect out of the previous rect and draw it, marking the selected node as such by making the header bold
            Rect headerRect = new Rect(nodeRect.x, nodeRect.y, nodeRect.width, contentOffset.y);

            GUI.color = Color.white;
            GUI.Label(headerRect, Title, NodeEditorGUI.nodeLabelCentered);

            RTEditorGUI.Seperator(new Rect(nodeRect.x, nodeRect.y + contentOffset.y - 1, nodeRect.width, 0));

            // Begin the body frame around the NodeGUI
            Rect bodyRect = new Rect(nodeRect.x, nodeRect.y + contentOffset.y, nodeRect.width,
                                     nodeRect.height - contentOffset.y);

            GUI.BeginGroup(bodyRect);

            GUI.color         = Color.white;
            bodyRect.position = Vector2.zero;
            GUILayout.BeginArea(bodyRect);

            // Call NodeGUI
            GUI.changed = false;
            NodeGUI();

            if (Event.current.type == EventType.Repaint)
            {
                nodeGUIHeight = GUILayoutUtility.GetLastRect().max + contentOffset;
            }

            // End NodeGUI frame
            GUILayout.EndArea();
            GUI.EndGroup();

            // Automatically node if desired
            AutoLayoutNode();
        }
コード例 #5
0
        [EventHandlerAttribute(EventType.MouseDown, 110)] // Priority over hundred to make it call after the GUI
        private static void HandleNodeDraggingStart(NodeEditorInputInfo inputInfo)
        {
            if (GUIUtility.hotControl > 0)
            {
                return; // GUI has control
            }
            NodeEditorState state = inputInfo.editorState;

            if (inputInfo.inputEvent.button == 0 && state.focusedNode != null && NodeEditor.CheckNodeIsSelected(state.focusedNode) &&
                state.focusedConnectionKnob == null)
            {
                // Clicked inside the selected Node, so start dragging it
                state.dragNode = true;
                state.StartDrag("node", inputInfo.inputPos, state.focusedNode.rect.position);
            }
        }
コード例 #6
0
        /// <summary>
        /// Draws the node frame and calls NodeGUI. Can be overridden to customize drawing.
        /// </summary>
        protected internal virtual void DrawNode()
        {
            // Create a rect that is adjusted to the editor zoom and pixel perfect
            Rect    nodeRect = rect;
            Vector2 pos      = NodeEditor.curEditorState.zoomPanAdjust + NodeEditor.curEditorState.panOffset;

            nodeRect.position = new Vector2((int)(nodeRect.x + pos.x), (int)(nodeRect.y + pos.y));

            //如果选中绘制白色描边,否则绘制黑色描边
            Rect outlineRect = new Rect(nodeRect.position.x - 6f, nodeRect.position.y - 6f, rect.size.x + 12, this.rect.size.y + 12);

            GUI.color = NodeEditor.CheckNodeIsSelected(this)? Color.white : Color.black;

            GUI.Box(outlineRect, "", NodeEditorGUI.nodeBox_HighLightOutLine);

            GUI.color = backgroundColor;

            GUI.Box(nodeRect, GUIContent.none, NodeEditorGUI.nodeBox);

            contentOffset = new Vector2(0, 20);

            // Create a headerRect out of the previous rect and draw it, marking the selected node as such by making the header bold
            Rect headerRect = new Rect(nodeRect.x, nodeRect.y, nodeRect.width, contentOffset.y);

            GUI.color = Color.white;
            GUI.Label(headerRect, Title, NodeEditorGUI.nodeTittleCentered);

            // Begin the body frame around the NodeGUI
            Rect bodyRect = new Rect(nodeRect.x, nodeRect.y + contentOffset.y, nodeRect.width,
                                     nodeRect.height - contentOffset.y);

            GUILayout.BeginArea(bodyRect);

            // Call NodeGUI
            NodeGUI();

            if (Event.current.type == EventType.Repaint && nodeGUIHeight != GUILayoutUtility.GetLastRect().max)
            {
                nodeGUIHeight = GUILayoutUtility.GetLastRect().max + contentOffset;
            }

            // End NodeGUI frame
            GUILayout.EndArea();

            // Automatically node if desired
            AutoLayoutNode();
        }