Example #1
0
        protected virtual void DoNode(Node node)
        {
            string nodename  = node.name;
            int    nodecolor = 0;

            if (node.name == "Base" && node.groupPath == "Base")
            {
            }
            else
            {
                if (node == startNode || node.GetPath() == groupPaths)
                {
                    nodecolor = 5;
                }
                if (node.GetPath() == groupPaths)
                {
                    nodecolor = 4;
                    string[] namepath = node.GetPath().Split('/');
                    nodename = "(Up) " + (namepath.Length > 1 ? namepath [namepath.Length - 2] : namepath [0]);
                }
                nodecolor = GetNodeColor(nodecolor, node);
                bool isGroupStyle;
                isGroupStyle = node.type == NodeType.NodeGroup;
                isGroupStyle = GetNodeStyle(isGroupStyle, node);
                GUIStyle style = NodeStyles.GetNodeStyle(nodecolor, selectNodes.Contains(node), isGroupStyle);
                Rect     pos   = new Rect((offset.x + node.position.x) * scale, (offset.y + node.position.y) * scale, node.position.width * scale, node.position.height * scale);
                GUI.Box(pos, nodename, style);
                Rect  inforect = pos;
                float cacheY   = inforect.y + node.position.height;
                for (int i = 0; i < node.infos.Length; i++)
                {
//
                    if (node.infos [i].text != "")
                    {
                        float h;
                        inforect.y      = cacheY;
                        h               = node.infos [i].text.Split('\n').Length * 16;
                        h               = h == 16 ? 20 : h;
                        inforect.height = h;
                        GUILayout.BeginArea(inforect);
                        try{
                            GUILayout.TextArea(node.infos [i].text);
                        }catch {
                        }

                        GUILayout.EndArea();

                        cacheY += inforect.width;
                    }
//
                }
            }
        }
Example #2
0
        /// <summary>
        /// 开始绘制节点
        /// </summary>
        /// <param name="node">Node.</param>
        protected virtual void DoNode(Node node)
        {
            Rect rect       = node.position;
            Rect nowCanvasR = canvasRect;

            nowCanvasR.position = -_canvasOffset;
            if (rect.xMax < nowCanvasR.x || rect.x > nowCanvasR.xMax || rect.yMax < nowCanvasR.y - nowCanvasR.height || rect.y > nowCanvasR.yMax)
            {
                return;
            }

            string nodename  = node.DrawNodeName;
            int    nodecolor = 0;

            if (node.name == "Base" && node.groupPath == "Base")
            {
            }
            else
            {
                if (node == _startNode || node.GetPath() == _currentGroupPath)
                {
                    nodecolor = 5;
                }
                if (node.GetPath() == _currentGroupPath)
                {
                    nodecolor = 4;
                    string[] namepath = node.GetPath().Split('/');
                    nodename = "(Up) " + (namepath.Length > 1 ? namepath [namepath.Length - 2] : namepath [0]);
                }
                nodecolor = GetNodeColor(nodecolor, node);
                bool isGroupStyle;
                isGroupStyle = node.type == NodeType.NodeGroup;
                isGroupStyle = GetNodeStyle(isGroupStyle, node);
                GUIStyle style = NodeStyles.GetNodeStyle(nodecolor, _selectNodes.Contains(node), isGroupStyle);
                Rect     pos   = new Rect((_canvasOffset.x + node.position.x) * _scale, (_canvasOffset.y + node.position.y) * _scale, node.position.width * _scale, node.position.height * _scale);
                GUI.Box(pos, nodename, style);
                if (node.ShowNodeProgressBar)
                {
                    Rect progress = pos;
                    progress.height = 10;
                    progress.y     += 20;
                    EditorGUI.ProgressBar(progress, node.nodeProgressBar, "");
                }
                Rect  inforect = pos;
                float cacheY   = inforect.y + node.position.height;
                for (int i = 0; i < node.infos.Length; i++)
                {
                    if (node.infos [i].text != "")
                    {
                        float h;
                        inforect.y      = cacheY;
                        h               = node.infos [i].text.Split('\n').Length * 16;
                        h               = h == 16 ? 20 : h;
                        inforect.height = h;
                        GUILayout.BeginArea(inforect);
                        try {
                            GUILayout.TextArea(node.infos [i].text);
                        } catch {
                        }

                        GUILayout.EndArea();

                        cacheY += inforect.width;
                    }
                }
            }
        }