Esempio n. 1
0
        /// <summary>
        /// draw view GUI, buttons and all
        /// </summary>
        public override void DrawView(Rect editorRect, Rect PercentRect, Event e, NodeGraph graph)
        {
            base.DrawView(editorRect, PercentRect, e, graph);
            ProcessEvents(e);
            if (graph != null)
            {
                title = graph.name;
            }
            else
            {
                title = GetTitle();
            }

            GUI.DrawTextureWithTexCoords(new Rect(body.position + pan, body.size), backgroundTexture, new Rect(0, 0, body.width / backgroundTexture.width,
                                                                                                               body.height / backgroundTexture.height));
            GUI.Box(body, title, skin.GetStyle("WorkViewBackground"));
            if (graph != null)
            {
                float btnH = 25, btnMY = 10;
                graph.DrawGraph(e, body);
                if (GUI.Button(new Rect(0, editorRect.y + btnMY, 80, btnH), "Compile"))
                {
                    graph.Compile();
                }
                GUI.Toggle(new Rect(100, editorRect.y + btnMY, 200, btnH), graph.compiled, "Has Compiled: ");
                if (GUI.Button(new Rect(0, editorRect.y + btnH + 2 * btnMY, 80, btnH), "Save"))
                {
                    NodeUtilities.UpdateGraph(graph);
                }
                if (GUI.Button(new Rect(0, editorRect.y + 2 * (btnH + 2 * btnMY), 80, btnH), "Resize"))
                {
                    foreach (NodeBase n in graph.nodes)
                    {
                        n.Resize(true);
                    }
                }
            }

            if (SelectedPin != null)
            {
                // is a window currently showing? if so, don't constantly draw to mouse pos
                if (NCPopup != null)
                {
                    DrawConnectionToMouse(NCPopup.mouseLoc);
                }
                else if (window.nodeCreateView != null)
                {
                    DrawConnectionToMouse(window.nodeCreateView.mouseLoc);
                }
                else
                {
                    DrawConnectionToMouse(e.mousePosition);
                }
            }
        }