示例#1
0
        public void Draw()
        {
            Vector2 startPositionInWindow = graph.GraphPositionToWindowPosition(rectInGraph.position);
            Vector2 endPositionInWindow   = graph.GraphPositionToWindowPosition(rectInGraph.max);

            rectInWindow.position = startPositionInWindow;
            rectInWindow.max      = endPositionInWindow;
            UpdateHeadRect();

            GUI.DrawTexture(rectInWindow, Utility.GetCommentBoxTexture(), ScaleMode.StretchToFill, true);
            GUI.DrawTexture(headRectInWindow, Utility.GetCommentBoxTexture(), ScaleMode.StretchToFill, true);

            if (comment == null)
            {
                comment = string.Empty;
            }

            if (isEditingComment)
            {
                if (GUI.GetNameOfFocusedControl() != "CommentEditArea")
                {
                    GUI.FocusControl("CommentEditArea");
                    GUI.SetNextControlName("CommentEditArea");
                }

                comment = GUI.TextArea(rectInWindow, comment, Utility.GetGuiStyle("CommentText"));
            }
            else
            {
                GUI.Label(rectInWindow, comment, Utility.GetGuiStyle("CommentText"));
            }
        }
示例#2
0
        public CommentBoxView(GraphEditorWindow graph, Vector2 startPositionInGraph, Vector2 endPositionInGraph)
        {
            this.graph  = graph;
            rectInGraph = new Rect(startPositionInGraph,
                                   new Vector2(endPositionInGraph.x - startPositionInGraph.x, endPositionInGraph.y - startPositionInGraph.y));

            rectInWindow.position = graph.GraphPositionToWindowPosition(rectInGraph.position);
            rectInWindow.max      = graph.GraphPositionToWindowPosition(rectInGraph.max);
        }
示例#3
0
        public static void DrawDraggingCommentBox(GraphEditorWindow graph, Vector2 startPositionInGraph,
                                                  Vector2 endPositionInGraph)
        {
            Vector2 startPositionInWindow = graph.GraphPositionToWindowPosition(startPositionInGraph);
            Vector2 endPositionInWindow   = graph.GraphPositionToWindowPosition(endPositionInGraph);

            Rect drawRect = new Rect(startPositionInWindow,
                                     new Vector2(endPositionInWindow.x - startPositionInWindow.x, endPositionInWindow.y - startPositionInWindow.y));

            GUI.DrawTexture(drawRect, Utility.GetCommentBoxTexture(), ScaleMode.StretchToFill, true);
        }
示例#4
0
        public CommentBoxView(GraphEditorWindow graph, Vector2 startPositionInGraph, Vector2 endPositionInGraph, string comment)
        {
            this.graph  = graph;
            rectInGraph = new Rect(startPositionInGraph,
                                   new Vector2(endPositionInGraph.x - startPositionInGraph.x, endPositionInGraph.y - startPositionInGraph.y));

            rectInWindow.position = graph.GraphPositionToWindowPosition(rectInGraph.position);
            rectInWindow.max      = graph.GraphPositionToWindowPosition(rectInGraph.max);
            UpdateHeadRect();

            this.comment = comment;
        }
示例#5
0
        public NodeEditorView(Vector2 graphPosition, GraphEditorWindow graph, int nodeId, NodeReflectionInfo reflectionInfo)
        {
            this.graph          = graph;
            this.NodeId         = nodeId;
            this.ReflectionInfo = reflectionInfo;

            PositionInGraph  = graphPosition;
            PositionInWindow = graph.GraphPositionToWindowPosition(graphPosition);

            viewRect = new Rect(Vector2.zero, new Vector2(200, 400));

            allPortList        = new List <PortEditorView>();
            inputPortViewList  = new List <InputPortEditorView>();
            outputPortViewList = new List <OutputPortEditorView>();

            leftPortLayoutHelper  = new PortLayoutHelper();
            rightPortLayoutHelper = new PortLayoutHelper();

            if (reflectionInfo.HasFlowInPort)
            {
                flowInPortView        = new FlowInPortEditorView(this);
                flowInPortView.portId = 0;
                allPortList.Add(flowInPortView);
            }

            if (reflectionInfo.flowOutPortDefineAttributes.Length > 0)
            {
                flowOutPortViews = new FlowOutPortEditorView[reflectionInfo.flowOutPortDefineAttributes.Length];
                for (int i = 0; i < flowOutPortViews.Length; i++)
                {
                    flowOutPortViews[i]        = new FlowOutPortEditorView(this, reflectionInfo.flowOutPortDefineAttributes[i]);
                    flowOutPortViews[i].portId = i;
                    allPortList.Add(flowOutPortViews[i]);
                }
            }
            else
            {
                flowOutPortViews = new FlowOutPortEditorView[0];
            }

            List <InputPortReflectionInfo> inputPortReflectionInfos = reflectionInfo.inputPortInfoList;

            for (int i = 0; i < inputPortReflectionInfos.Count; i++)
            {
                InputPortReflectionInfo inputPortReflectionInfo = inputPortReflectionInfos[i];
                InputPortEditorView     inputPortView           = new InputPortEditorView(this, inputPortReflectionInfo);
                inputPortView.portId = i;

                inputPortViewList.Add(inputPortView);
                allPortList.Add(inputPortView);
            }

            List <OutputPortReflectionInfo> outputPortReflectionInfos = reflectionInfo.outputPortInfoList;

            for (int i = 0; i < outputPortReflectionInfos.Count; i++)
            {
                OutputPortReflectionInfo outputPortReflectionInfo = outputPortReflectionInfos[i];
                OutputPortEditorView     outputPortView           = new OutputPortEditorView(this, outputPortReflectionInfo, i);
                outputPortView.portId = i;

                outputPortViewList.Add(outputPortView);
                allPortList.Add(outputPortView);
            }

            CalculateNodeSize();
        }
示例#6
0
        public void DrawNodeGUI()
        {
            if (graph == null)
            {
                return;
            }

            PositionInWindow = graph.GraphPositionToWindowPosition(PositionInGraph);
            viewRect.center  = PositionInWindow;

            if (isSelected)
            {
                Rect highLightRect = new Rect(viewRect);
                highLightRect.position = highLightRect.position - Vector2.one * 2f;
                highLightRect.max      = highLightRect.max + Vector2.one * 4f;
                GUI.Box(highLightRect, "", Utility.GetGuiStyle("Highlight"));
            }

            //draw back ground
            if (ReflectionInfo.IsEntranceNode)
            {
                GUI.Box(viewRect, "", Utility.GetGuiStyle("EntranceNode"));
            }

            if (ReflectionInfo.Type.IsSubclassOf(typeof(GraphVariableNodeBase)))
            {
                GUI.Box(viewRect, "", Utility.GetGuiStyle("NodeCyan"));
            }
            else
            {
                GUI.Box(viewRect, "", Utility.GetGuiStyle("NodeBg"));
            }

            //draw node name
            GUI.Label(NodeNameRect, string.Format("({0}){1}", NodeId, ReflectionInfo.NodeName), Utility.GetGuiStyle("NodeName"));

            leftPortLayoutHelper.SetPosition(new Vector2(viewRect.x, viewRect.y + NodeNameRect.height + PortAreaPadding));
            rightPortLayoutHelper.SetPosition(new Vector2(viewRect.x, viewRect.y + NodeNameRect.height + PortAreaPadding));

            if (flowInPortView != null)
            {
                flowInPortView.portViewRect = leftPortLayoutHelper.GetRect();
            }

            for (int i = 0; i < inputPortViewList.Count; i++)
            {
                InputPortEditorView inputPortView = inputPortViewList[i];
                inputPortView.portViewRect = leftPortLayoutHelper.GetRect();
            }

            if (flowOutPortViews.Length > 0)
            {
                for (int i = 0; i < flowOutPortViews.Length; i++)
                {
                    FlowOutPortEditorView flowoutPortView = flowOutPortViews[i];
                    flowoutPortView.portViewRect = rightPortLayoutHelper.GetRect();
                }
            }

            for (int i = 0; i < outputPortViewList.Count; i++)
            {
                OutputPortEditorView outputPortView = outputPortViewList[i];
                outputPortView.portViewRect = rightPortLayoutHelper.GetRect();
            }

            for (int i = 0; i < allPortList.Count; i++)
            {
                PortEditorView portView = allPortList[i];

                portView.Draw();
            }
        }