private void OnGUI()
    {
        _zoomArea.height = position.height;
        _zoomArea.width  = position.width;

        ZoomedArea = EditorZoomArea.Begin(zoomScale, _zoomArea);

        DrawGrid(20, 0.2f, Color.gray);
        DrawGrid(100, 0.4f, Color.gray);

        DrawConnections();
        DrawNodes();

        DrawConnectionLine(Event.current);


        ProcessNodeEvents(Event.current);
        //reset the matrix
        EditorZoomArea.End();

        ProcessEvents(Event.current);

        if (GUI.changed)
        {
            Repaint();
        }
    }
    private void OnGUI()
    {
        _zoomArea = new Rect(0.0f, 0, Screen.width, Screen.height);

        EditorZoomArea.Begin(_zoom, _zoomArea);
        {
            GUI.Box(new Rect(0.0f + _zoomCoordsOrigin.x, 0.0f + _zoomCoordsOrigin.y, 100.0f, 25.0f), "Zoomed Box");

            // You can also use GUILayout inside the zoomed area.
            GUILayout.BeginArea(new Rect(300.0f + _zoomCoordsOrigin.x, 70.0f + _zoomCoordsOrigin.y, 130.0f, 50.0f));
            GUILayout.Button("Zoomed Button 1");
            GUILayout.Button("Zoomed Button 2");
            GUILayout.EndArea();

            DrawGrid(20, 0.2f, Color.gray);
            DrawGrid(100, 0.4f, Color.gray);

            DrawDebug();

            DrawNodes();
            DrawConnections();

            DrawConnectionLine(Event.current);

            ProcessNodeEvents(Event.current);
            ProcessEvents(Event.current);
        }
        EditorZoomArea.End();
        if (GUI.changed)
        {
            Repaint();
        }
    }
        private void DrawZoomArea()
        {
            Handles.DrawSolidRectangleWithOutline(new Rect(leftPanelWidth, topPanelHeight, position.width - leftPanelWidth, position.height - topPanelHeight), new Color(0.14f, 0.14f, 0.14f), Color.clear);

            // Within the zoom area all coordinates are relative to the top left corner of the zoom area
            // with the width and height being scaled versions of the original/unzoomed area's width and height.
            EditorZoomArea.Begin(zoom, zoomArea);

            if (CurrentGraph != null)
            {
                foreach (var asset in CurrentGraph.Nodes)
                {
                    GUI.Box(new Rect(asset.Position.x - zoomCoordsOrigin.x, asset.Position.y - zoomCoordsOrigin.y, asset.Size.x, asset.Size.y), asset.Title);
                }
            }

            // GUI.Box(new Rect(0.0f - zoomCoordsOrigin.x, 0.0f - zoomCoordsOrigin.y, 100.0f, 25.0f), "Zoomed Box");

            // You can also use GUILayout inside the zoomed area.
            GUILayout.BeginArea(new Rect(300.0f - zoomCoordsOrigin.x, 70.0f - zoomCoordsOrigin.y, 130.0f, 50.0f));
            GUILayout.Button("Zoomed Button 1");
            GUILayout.Button("Zoomed Button 2");
            GUILayout.EndArea();

            EditorZoomArea.End();
        }
        private void OnGUI()
        {
            if (tex == null)
            {
                tex = AssetDatabase.LoadAssetAtPath <Texture>("Assets/AndreLibrary/Editor/BT/BT_Lighter_Black.jpg");
            }

            GUI.DrawTexture(new Rect(0, 0, maxSize.x, maxSize.y), tex, ScaleMode.StretchToFill);

            DrawGrid(20, 0.2f, Color.gray);
            DrawGrid(100, 0.4f, Color.gray);

            if (window != null)
            {
                _zoomArea = new Rect(0, 0, window.position.width, window.position.height);
            }
            if (BehaviourTree != null)
            {
                if (BehaviourTree.root != null)
                {
                    EditorZoomArea.Begin(_zoom, _zoomArea);
                    BehaviourTree.root.DrawInEditor(Event.current);
                    AssetToUpdate = BehaviourTree.root.ProcessNodeEvents(Event.current);
                    EditorZoomArea.End();
                }
                HelperWindow();
                ProcessEvents(Event.current);
                Repaint();
            }
        }
Exemple #5
0
    private void OnGUI()
    {
        _zoomArea = new Rect(0.0f, 0, Screen.width, Screen.height);

        EditorZoomArea.Begin(_zoom, _zoomArea);
        {
            /*
             * GUI.Box(new Rect(0.0f + _zoomCoordsOrigin.x, 0.0f + _zoomCoordsOrigin.y, 100.0f, 25.0f), "Zoomed Box");
             *
             * // You can also use GUILayout inside the zoomed area.
             * GUILayout.BeginArea(new Rect(300.0f + _zoomCoordsOrigin.x, 70.0f + _zoomCoordsOrigin.y, 130.0f, 50.0f));
             * GUILayout.Button("Zoomed Button 1");
             * GUILayout.Button("Zoomed Button 2");
             * GUILayout.EndArea();
             */

            DrawGrid(20, 0.2f, Color.gray);
            DrawGrid(100, 0.4f, Color.gray);

            foreach (EndlessWindowItem ewi in items)
            {
                ewi.Draw(_zoomCoordsOrigin);
            }

            ProcessEvents(Event.current);
        }

        EditorZoomArea.End();
        if (GUI.changed)
        {
            Repaint();
        }
    }
        void DrawNode()
        {
            scriptViewRect = new Rect(nodeViewContianer.contentRect.x, nodeViewContianer.contentRect.y - menuBarHeight + 2, nodeViewContianer.contentRect.width / zoomScale, nodeViewContianer.contentRect.height / zoomScale);

            EditorZoomArea.NoGroupBegin(zoomScale, scriptViewRect);
            DrawGrid();

            foreach (var item in viewStateList.ToArray())
            {
                if (!string.IsNullOrEmpty(item.viewState.name))
                {
                    //Draw Bounds
                    calculateCache.Clear();
                    calculateCache.Add(item.drawRect);
                    if (viewPageList.Count(m => m.viewPage.viewState == item.viewState.name) > 0)
                    {
                        calculateCache.AddRange(viewPageList.Where(m => m.viewPage.viewState == item.viewState.name).Select(m => m.drawRect));
                        Rect rect = VS_EditorUtility.CalculateBoundsRectFromRects(calculateCache, new Vector2(20, 20));
                        GUI.Box(rect, "", new GUIStyle("SelectionRect"));
                    }
                }
                item.Draw(false);
            }
            foreach (var item in viewPageList.ToArray())
            {
                bool highlight = false;
                if (Application.isPlaying && ViewController.Instance != null)
                {
                    if (item.viewPage.viewPageType == ViewPage.ViewPageType.FullPage)
                    {
                        highlight = ViewController.Instance.currentViewPage.name == item.name;
                    }
                    else
                    {
                        highlight = ViewController.Instance.IsOverPageLive(item.name);
                    }
                }
                else
                {
                    highlight = !string.IsNullOrEmpty(search) && item.name.ToLower().Contains(search.ToLower());
                }

                item.Draw(highlight);
            }

            DrawCurrentConnectionLine(Event.current);
            EditorZoomArea.NoGroupEnd();

            DrawFloatWindow();

            ProcessEvents(Event.current);
            CheckRepaint();
        }
Exemple #7
0
 private void DrawZoomArea()
 {
     EditorZoomArea.Begin(_canvas.Zoom, _zoomArea);
     _canvas.DrawArea.Set(_canvas.Position.x, _canvas.Position.y, 100000.0f, 100000.0f);
     GUILayout.BeginArea(_canvas.DrawArea, _canvas.Style);
     _canvas.DrawEdges();
     BeginWindows();
     _canvas.DrawNodes();
     EndWindows();
     DrawDragEdge();
     GUILayout.EndArea();
     EditorZoomArea.End();
 }
        void DrawWindows()
        {
            EditorZoomArea.Begin(_zoom, _zoomArea);

            Rect all = new Rect(0.0f - _zoomCoordsOrigin.x, 0.0f - _zoomCoordsOrigin.y, _zoomArea.width, _zoomArea.height);

            GUILayout.BeginArea(all, style);

            BeginWindows();
            EditorGUILayout.LabelField(" ", GUILayout.Width(100));
            EditorGUILayout.LabelField("Assign Graph:", GUILayout.Width(100));
            settings.currentGraph = (BehaviorGraph)EditorGUILayout.ObjectField(settings.currentGraph, typeof(BehaviorGraph), false, GUILayout.Width(200));

            if (settings.currentGraph != null)
            {
                foreach (BaseNode n in settings.currentGraph.windows)
                {
                    n.DrawCurve();
                }

                for (int i = 0; i < settings.currentGraph.windows.Count; i++)
                {
                    BaseNode b = settings.currentGraph.windows[i];
                    b.SetZoomedWindowRect(_zoomCoordsOrigin, _zoom);

                    if (b.drawNode is StateNode)
                    {
                        if (currentStateManager != null && b.stateRef.currentState == currentStateManager.currentState)
                        {
                            b.windowRect = GUILayout.Window(i, b.windowRect,
                                                            DrawNodeWindow, b.windowTitle, activeStyle);
                        }
                        else
                        {
                            b.windowRect = GUILayout.Window(i, b.windowRect,
                                                            DrawNodeWindow, b.windowTitle);
                        }
                    }
                    else
                    {
                        b.windowRect = GUILayout.Window(i, b.windowRect,
                                                        DrawNodeWindow, b.windowTitle);
                    }
                }
            }
            EndWindows();

            GUILayout.EndArea();

            EditorZoomArea.End();
        }
Exemple #9
0
    void DrawGraphCanvas()
    {
        // Within the zoom area all coordinates are relative to the top left corner of the zoom area
        // with the width and height being scaled versions of the original/unzoomed area's width and height.
        EditorZoomArea.Begin(zoomLevel, zoomArea);

        // Draw grid?
        DrawGrid(20f, 0.2f, Color.gray);
        DrawGrid(100f, 0.4f, Color.gray);

        DrawElements();

        EditorZoomArea.End();
    }
Exemple #10
0
        public void OnGUI()
        {
            if (parentEtude == BlueprintGuid.Empty)
            {
                return;
            }

            //HandleEvents();

            UI.Label($"Child Etudes: {loadedEtudes[parentEtude].Name}", UI.AutoWidth());

            //GUI.DrawTextureWithTexCoords(workspaceRect, etudeViewer.grid,
            //    new Rect(_zoomCoordsOrigin.x / 30, -_zoomCoordsOrigin.y / 30, workspaceRect.width / (30 * _zoom),
            //        workspaceRect.height / (30 * _zoom)));

#if false
            PrepareLayout();
            DrawSelection();
            DrawLines();
            DrawEtudes();
            DrawReferences();
            DrawFind();
            GUILayout.EndArea();
            EditorZoomArea.End();

            if (newParentFromContestComand)
            {
                if (loadedEtudes.ContainsKey(newParentID))
                {
                    BlueprintEtude clickedEtude = (BlueprintEtude)ResourcesLibrary.TryGetBlueprint(newParentID);
                    Selection.activeObject = BlueprintEditorWrapper.Wrap(clickedEtude);

                    if (clickedEtude.Parent.IsEmpty())
                    {
                        parentEtude = clickedEtude.AssetGuid;
                    }
                    else
                    {
                        parentEtude = clickedEtude.Parent.GetBlueprint().AssetGuid;
                    }

                    etudeDrawerData    = new Dictionary <BlueprintGuid, EtudeDrawerData>();
                    _zoomCoordsOrigin  = Vector2.zero;
                    FirstLayoutProcess = true;
                }

                newParentFromContestComand = false;
            }
#endif
        }
        public virtual void DrawWindows()
        {
            if (currentGraph != null)
            {
                EditorZoomArea.Begin(_zoom, new Rect(0, 0, Screen.width, Screen.width));
                GUILayout.BeginArea(all);
                BeginWindows();

                currentGraph?.RemoveNodeSelectedNodes();

                for (int i = 0; i < currentGraph.nodes.Count; i++)
                {
                    BaseNode n = currentGraph.nodes[i];

                    foreach (Transition t in n.transitions)
                    {
                        if (!currentGraph.nodes.Contains(t.endNode))
                        {
                            n.AddTransitionsToRemove(t.ID);
                            Repaint();
                        }
                    }


                    if (n.WindowRect.size != Vector2.zero) // if node is in zone and zone is not collapsed
                    {
                        EditorGUI.DrawRect(new Rect(n.WindowRect.position, 2 * Vector2.one), Color.red);

                        n.WindowRect = GUI.Window(i, n.WindowRect, DrawNodeWindow, n.WindowTitle + (n.drawNode is EnterNode ? "" : " id: " + n.ID)); // setting up nodes as windows
                    }

                    n.DrawCurve(); // drawing transitions
                }

                EndWindows();
                GUILayout.EndArea();
                EditorZoomArea.End(all);

                foreach (BaseNode b in currentGraph.nodes)
                {
                    foreach (Transition t in b.transitions)
                    {
                        DrawTransitionSettings(t);
                    }
                }
            }

            currentGraph?.RemoveTransitions();
        }
    private void DrawZoomArea()
    {
        // Within the zoom area all coordinates are relative to the top left corner of the zoom area
        // with the width and height being scaled versions of the original/unzoomed area's width and height.
        EditorZoomArea.Begin(_zoom, _zoomArea);

        GUI.Box(new Rect(0.0f - _zoomCoordsOrigin.x, 0.0f - _zoomCoordsOrigin.y, 100.0f, 25.0f), "Zoomed Box");

        // You can also use GUILayout inside the zoomed area.
        GUILayout.BeginArea(new Rect(300.0f - _zoomCoordsOrigin.x, 70.0f - _zoomCoordsOrigin.y, 130.0f, 50.0f));
        GUILayout.Button("Zoomed Button 1");
        GUILayout.Button("Zoomed Button 2");
        GUILayout.EndArea();

        EditorZoomArea.End();
    }
    void DrawZoomArea()
    {
        zoomAreaRect.Set(0, 17, position.width, position.height - 17);

        if (Background != null)
        {
            var uvOffset = new Vector2(-zoomAreaOrigin.x / Background.width,
                                       (zoomAreaOrigin.y - zoomAreaRect.height / zoom) / Background.height);

            var uvSize = new Vector2(zoomAreaRect.width / (Background.width * zoom),
                                     zoomAreaRect.height / (Background.height * zoom));

            GUI.DrawTextureWithTexCoords(zoomAreaRect, Background, new Rect(uvOffset, uvSize));
        }

        EditorZoomArea.Begin(zoom, zoomAreaRect);
        DrawZoomAreaContents(zoomAreaOrigin);
        EditorZoomArea.End();
    }
Exemple #14
0
    private void DrawZoomArea()
    {
        // Within the zoom area all coordinates are relative to the top left corner of the zoom area
        // with the width and height being scaled versions of the original/unzoomed area's width and height.
        _zoomArea   = position;
        _zoomArea.x = 0f; _zoomArea.y = 0f;
        EditorZoomArea.Begin(_zoom, _zoomArea);

        GUI.DrawTexture(new Rect(0, 0, _zoomArea.width / _zoom, _zoomArea.height / _zoom), backgroundTex, ScaleMode.StretchToFill); //draw background


        DrawGrid(20, 0.2f, smallGridColor);
        DrawGrid(100, 0.4f, bigGridColor);

        DrawNodes();
        DrawConnections();

        DrawConnectionLine(Event.current);

        EditorZoomArea.End();
    }
 // Node Utility
 public void DrawNodes()
 {
     if (uNodeEditor.editor == null || currentCanvas == null)
     {
         return;
     }
     EditorZoomArea.Begin(uNodeEditorState.zoom, uNodeEditor.editor.CanvasWindowRect);
     // Draw all nodes
     for (int i = 0; i < currentCanvas.Nodes.Count; i++)
     {
         currentCanvas.Nodes[i].DrawNodeBase();
     }
     // Draw the line being created by the user to connect two nodes
     if (uNodeEditorState.currentLineDrawn != null)
     {
         Handles.BeginGUI();
         Handles.color = Color.red;
         Handles.DrawLine(uNodeEditorState.currentLineDrawn.start, uNodeEditorState.currentLineDrawn.end);
         Handles.EndGUI();
     }
     EditorZoomArea.End();
 }
Exemple #16
0
    public void DrawZoomArea()
    {
        AIManager manager = AIManager.s_instance;

        // Start zoomed drawing using the dimensions of the menu section as bounds.
        EditorZoomArea.Begin(manager.m_zoom, new Rect(0.0f, manager.m_buttonBarHeight, position.width, position.height));

        // Mouse-down scrolling
        if (Event.current.type == EventType.mouseDown && Event.current.button == 2)
        {
            m_scrollStart = Event.current.mousePosition;
        }

        // These checks fire when I've bodged data during development
        if (manager.selectedTaskIndex == -1)
        {
            return;
        }
        if (manager.selectedTaskIndex >= manager.m_tasks.Count)
        {
            return;
        }


        AITask currentTask = manager.m_tasks[manager.selectedTaskIndex];

        //return;
        // Draw the temporary line when the user is making links

        /*
         *  if(manager.m_dragStart != null)
         *  {
         *      AIAction source = manager.m_dragStart;
         *
         *      Vector2 start = new Vector2(source.m_editorPosition.x + source.m_windowWidth + stateHandleSize.x / 2.0f + m_scrollOffset.x, source.m_editorPosition.y + source.m_lastBounds.y + m_scrollOffset.y + stateHandleSize.y / 2.0f);
         *      Vector2 end = Event.current.mousePosition;
         *
         *      Drawing.bezierLine(start, start + (Vector2.right * lineCurveScale), end, end + (new Vector2(-1.0f, 0.0f) * lineCurveScale), Color.red, 1.0f, true, 20);
         *  }
         */
        // TODO: Loads of these loops can be removed with decent layering
        // TODO: Only redraw when moved or connections changed!
        // Draw connections

        foreach (var action in currentTask.Actions)
        {
            float delta      = 1.0f / action.Outputs.Count;
            float currentVal = 0.0f;
            float expansion  = 30.0f;
            for (int index = 0; index < action.Outputs.Count; index++)
            {
                AIAction linkedAction = action.GetOutput(index);
                if (linkedAction != null)
                {
                    Vector2 start = new Vector2(action.m_editorPosition.x + action.Outputs[index].outputRect.x + action.Outputs[index].outputRect.width + 10, action.m_editorPosition.y + action.Outputs[index].outputRect.y + 10);
                    Vector2 end   = new Vector2(linkedAction.m_editorPosition.x - 5, linkedAction.m_editorPosition.y + linkedAction.m_lastBounds.height / 2.0f);

                    start.x += m_scrollOffset.x;
                    start.y += m_scrollOffset.y;

                    end.x += m_scrollOffset.x;
                    end.y += m_scrollOffset.y;

                    if (action == linkedAction)
                    {
                        Vector2 right    = start + (new Vector2(10.0f + (expansion * currentVal), 0.0f));
                        Vector2 rightTop = right;
                        rightTop.y = action.m_editorPosition.y + m_scrollOffset.y - 50 - (expansion * currentVal);

                        Vector2 leftTop = rightTop;
                        leftTop.x = end.x - 10.0f - (expansion * currentVal);

                        Vector2 left = leftTop;
                        left.y = end.y;

                        Drawing.DrawLine(start, right, Color.red, 1.0f, true);
                        Drawing.DrawLine(right, rightTop, Color.red, 1.0f, true);
                        Drawing.DrawLine(rightTop, leftTop, Color.red, 1.0f, true);
                        Drawing.DrawLine(leftTop, left, Color.red, 1.0f, true);
                        Drawing.DrawLine(left, end, Color.red, 1.0f, true);
                    }
                    else
                    {
                        Drawing.DrawBezierLine(start, start + (Vector2.right * lineCurveScale), end, end + (new Vector2(-1.0f, 0.0f) * lineCurveScale), Color.yellow, 1.0f, true, 20);
                    }
                }
                currentVal += delta;
            }
        }

        // input button checks
        foreach (var action in currentTask.Actions)
        {
            if (GUI.Button(new Rect(action.m_editorPosition.x - 10 + m_scrollOffset.x, action.m_editorPosition.y + action.m_lastBounds.height / 2.0f + m_scrollOffset.y - 5, 10, 10), "x"))
            {
                if (manager.m_dragAction != null)
                {
                    manager.m_dragAction.SetOutput(manager.m_dragAction.Outputs[manager.m_dragActionOutput].linkName, action);
                }
            }
        }
        //Debug.Log(currentTask.m_actiontest);
        // Clear drag events on left-mouse click
        if (Event.current.type == EventType.MouseDown && Event.current.button == 0)
        {
            manager.m_dragAction = null;
        }

        // Show behaviour link output buttons
        foreach (var action in currentTask.Actions)
        {
            int index = 0;
            foreach (var output in action.Outputs)
            {
                GUI.depth = -1;
                if (GUI.Button(new Rect(action.m_editorPosition.x + action.Outputs[index].outputRect.x + action.Outputs[index].outputRect.width + m_scrollOffset.x + 5, action.m_editorPosition.y + action.Outputs[index].outputRect.y + m_scrollOffset.y + 5, 10, 10), "x"))
                {
                    action.SetOutput(output.linkName, null);
                    manager.m_dragAction       = action;
                    manager.m_dragActionOutput = index;
                }
                index++;
            }
        }

        GUI.depth = 1;


        // Draw nodes
        BeginWindows();

        for (int i = 0; i < currentTask.Actions.Count; i++)
        {
            Rect currentPos = currentTask.Actions[i].m_editorPosition;
            currentPos.x += m_scrollOffset.x;
            currentPos.y += m_scrollOffset.y;

            string name = currentTask.Actions[i].Name;

            Rect thing = GUILayout.Window(i, currentPos, DrawActionWindow, name);

            currentTask.Actions[i].m_editorPosition = thing;

            currentTask.Actions[i].m_editorPosition.x -= m_scrollOffset.x;
            currentTask.Actions[i].m_editorPosition.y -= m_scrollOffset.y;

            if (Event.current.type == EventType.repaint)
            {
                currentTask.Actions[i].m_windowWidth = thing.width;
                currentTask.Actions[i].m_lastBounds  = thing;
            }
        }

        EndWindows();

        // I have no idea why, but this nukes drag-scrolling if it's near the top of the function
        if (Event.current.type == EventType.mouseDrag)
        {
            if (Event.current.button == 2)
            {
                m_scrollOffset += (Event.current.mousePosition - m_scrollStart) / 2.0f;
                m_scrollStart   = Event.current.mousePosition;
            }
        }

        if (Event.current.type == EventType.ScrollWheel)
        {
            manager.m_zoom -= ((float)Event.current.delta.y * 0.01f);

            manager.m_zoom = Mathf.Max(0.5f, manager.m_zoom);
            manager.m_zoom = Mathf.Min(1.0f, manager.m_zoom);
        }

        // This is pretty shonky, but keeps things smooth.
        // Disable if performance gets choppy and work out something better
        Repaint();

        EditorZoomArea.End();
    }
Exemple #17
0
    private void DrawBoard()
    {
        // Prepare zoomable area.
        m_zoomArea = new Rect(m_propertyPanelWidth, 0, m_boardPanelWidth, Screen.height);

        // Draw background.
        EditorGUI.DrawRect(new Rect(m_propertyPanelWidth, 0, m_boardPanelWidth, Screen.height), new Color(0.1f, 0.1f, 0.1f));

        if (m_storyboardData == null)
        {
            return;
        }

        // Information.
        if (m_storyboardData && m_storyboardData.m_nodes.Count == 0)
        {
            EditorGUI.LabelField(new Rect(m_propertyPanelWidth + 20, 20, 100, 50), "No nodes found, please generate.", m_resources.m_mediumLabel);
        }

        // Begin zoom area.
        EditorZoomArea.Begin(m_zoomScale, m_zoomArea);

        Vector2 windowStartPosition = new Vector2(50, 50);
        Vector2 windowPosition      = windowStartPosition;
        int     horizontalCounter   = 0;
        Vector2 textureSize         = new Vector2(300, 300);
        Vector2 windowSize          = new Vector2(350, 510);

        float xAddition      = 150;
        float yAddition      = 100;
        float totalXAddition = windowSize.x + xAddition;
        float totalYAddition = windowSize.y + yAddition;

        Color windowColor = new Color(0.15f, 0.15f, 0.15f, 1.0f);
        Color windowBorderColorUnlocked = new Color(0.05f, 0.05f, 0.05f, 1.0f);
        Color windowBorderColorLocked   = new Color(0.05f, 0.35f, 0.05f, 1.0f);

        Color textureBorderColor = new Color(0.05f, 0.05f, 0.05f, 1.0f);

        ColorUtility.TryParseHtmlString("#53505A", out textureBorderColor);
        ColorUtility.TryParseHtmlString("#A58961", out windowBorderColorLocked);

        for (int i = 0; i < m_storyboardData.m_nodes.Count; i++)
        {
            StoryboardNode node = m_storyboardData.m_nodes[i];

            // m_storyboardData.m_nodes[i].m_rect = GUI.Window(i, m_storyboardData.m_nodes[i].m_rect, DrawNodeWindow,"");
            node.m_rect = new Rect(windowPosition.x - m_zoomCoordsOrigin.x, windowPosition.y - m_zoomCoordsOrigin.y, windowSize.x, windowSize.y);

            if (i != 0 && horizontalCounter != 0)
            {
                StoryboardNode previousNode = m_storyboardData.m_nodes[i - 1];
                DrawHorizontalNodeTransition(previousNode, node);
            }
            else if (i != 0 && horizontalCounter == 0)
            {
                StoryboardNode previousNode = m_storyboardData.m_nodes[i - 1];
                DrawVerticalNodeTransition(previousNode, node, yAddition);
            }


            if (horizontalCounter < 3)
            {
                windowPosition.x += totalXAddition;
                horizontalCounter++;
            }
            else
            {
                horizontalCounter = 0;
                windowPosition.y += totalYAddition;
                windowPosition.x  = windowStartPosition.x;
            }
        }

        // Draw each node.
        for (int i = 0; i < m_storyboardData.m_nodes.Count; i++)
        {
            StoryboardNode node = m_storyboardData.m_nodes[i];
            Color          windowBorderColor = node.m_isLocked ? windowBorderColorLocked : windowBorderColorUnlocked;
            Rect           nodeRect          = node.m_rect;

            // Outline
            EditorGUI.DrawRect(new Rect(nodeRect.x - 2, nodeRect.y - 2, nodeRect.width + 4, nodeRect.height + 4), windowBorderColor);

            // Window.
            EditorGUI.DrawRect(new Rect(nodeRect.x, nodeRect.y, nodeRect.width, nodeRect.height), windowColor);

            // Header
            GUI.Label(new Rect(nodeRect.x + 10, nodeRect.y + 10, 100, 50), "MARKER " + i.ToString(), m_resources.m_nodeTitleLabel);

            GUI.enabled = !node.m_isLocked;

            // Header buttons.
            if (GUI.Button(new Rect(nodeRect.x + windowSize.x - 160, nodeRect.y + 5, 75, 30), "Resimulate"))
            {
                m_simulator.Simulate(this, m_camera.transform, m_storyboardData, m_timeline, m_playableDirector,
                                     ref m_simulatedMarkers, m_debugPositioning, m_debugLook, m_debugTrack, m_debugFX, m_renderTexture, false, i);

                SaveSimulationTextures(false, i);
            }

            GUI.enabled = true;

            string lockButtonText = node.m_isLocked ? "Unlock" : "Lock";
            if (GUI.Button(new Rect(nodeRect.x + windowSize.x - 80, nodeRect.y + 5, 75, 30), lockButtonText, node.m_isLocked ? m_resources.m_lockButtonLockedStyle : m_resources.m_lockButtonUnlockedStyle))
            {
                node.m_isLocked = !node.m_isLocked;
            }

            // Header separator.
            for (int j = 0; j < 10; j++)
            {
                EditorGUI.DrawRect(new Rect(nodeRect.x, nodeRect.y + 40 + ((float)j * 1), windowSize.x, 1), new Color(0.0f, 0.0f, 0.0f, 0.5f - ((j + 1) * 0.05f)));
            }


            // Information.
            Rect fieldsRect = nodeRect;

            fieldsRect.x += 10;
            fieldsRect.y += 55;
            GUI.Label(fieldsRect, "Time: " + node.m_marker.time.ToString("F2"), m_resources.m_nodeFieldLabel);

            fieldsRect.y += 17.5f;

            if (node.m_marker.m_targets.Length > 1)
            {
                GUI.Label(fieldsRect, "Target: Multiple", m_resources.m_nodeFieldLabel);
            }
            else if (node.m_marker.m_targets.Length > 0)
            {
                GUI.Label(fieldsRect, "Target: Single", m_resources.m_nodeFieldLabel);
            }

            else
            {
                GUI.Label(fieldsRect, "Target: None", m_resources.m_nodeFieldLabel);
            }

            fieldsRect.y -= 17.5f;
            fieldsRect.x += windowSize.x - 170;
            GUI.Label(fieldsRect, "Dramatization: " + node.m_marker.m_dramatization.ToString("F2"), m_resources.m_nodeFieldLabel);

            fieldsRect.y += 17.5f;
            GUI.Label(fieldsRect, "Pace: " + node.m_marker.m_pace.ToString("F2"), m_resources.m_nodeFieldLabel);

            fieldsRect.y += 25;
            EditorGUI.DrawRect(new Rect(nodeRect.x, fieldsRect.y, windowSize.x, 1), new Color(0.0f, 0.0f, 0.0f, 0.5f));

            // Separator - Techniques
            fieldsRect.x  = nodeRect.x + 10;
            fieldsRect.y += 10;
            GUI.Label(fieldsRect, "Positioning: " + node.m_positioningTechnique.m_implementation.GetType().ToString(), m_resources.m_nodeFieldLabel);

            fieldsRect.y += 17.5f;
            GUI.Label(fieldsRect, "Look: " + node.m_lookTechnique.m_implementation.GetType().ToString(), m_resources.m_nodeFieldLabel);

            fieldsRect.y -= 17.5f;
            fieldsRect.x += windowSize.x - 170;
            GUI.Label(fieldsRect, "Track: " + node.m_trackTechnique.m_implementation.GetType().ToString(), m_resources.m_nodeFieldLabel);

            fieldsRect.y += 17.5f;
            GUI.Label(fieldsRect, "FX: " + node.m_fxTechnique.m_implementation.GetType().ToString(), m_resources.m_nodeFieldLabel);

            // Seperator - Preview
            fieldsRect.x  = nodeRect.x + 10;
            fieldsRect.y += 25;
            EditorGUI.DrawRect(new Rect(nodeRect.x, fieldsRect.y, windowSize.x, 1), new Color(0.0f, 0.0f, 0.0f, 0.5f));

            fieldsRect.y += 12;
            fieldsRect.x  = nodeRect.x + windowSize.x / 2.0f - fieldsRect.width / 8.0f;
            GUI.Label(fieldsRect, "Shot Preview", m_resources.m_nodeFieldLabel);

            // Texture border.
            fieldsRect.y     += 25;
            fieldsRect.x      = nodeRect.x + 25;
            fieldsRect.width  = textureSize.x;
            fieldsRect.height = textureSize.y;
            EditorGUI.DrawRect(fieldsRect, textureBorderColor);

            // Texture
            fieldsRect.x      += 2.5f;
            fieldsRect.y      += 2.5f;
            fieldsRect.width  -= 5;
            fieldsRect.height -= 5;
            GUI.DrawTexture(fieldsRect, m_storyboardData.m_nodes[i].m_simulationData.m_snapshots[0]);

            GUI.changed = true;
        }

        EditorZoomArea.End();
    }
Exemple #18
0
        private void OnGUI()
        {
            if (currentGraph == null)
            {
                ShowNotification(new GUIContent("Please Select a Graph before you start using the tool",
                                                Resources.Load <Texture>("tree_icon")));
            }

            _mousePosition = Event.current.mousePosition;

            //DrawBackgroundGrid(20, 0.2f, Color.grey);
            //DrawBackgroundGrid(100, 0.4f, Color.grey);

            ProcessEvents(Event.current);

            var controlsArea = DrawGlobalGuiControls();

            if (currentGraph == null)
            {
                if (GUI.changed)
                {
                    Repaint();
                }
                return;
            }

            Rect inspectorRect = new Rect(0, controlsArea.yMax, position.width / 4,
                                          position.height);

            EditorGUI.DrawRect(inspectorRect, new Color(0.33f, 0.27f, 0.33f, 0.27f));

            GUILayout.BeginArea(inspectorRect);
            GUILayout.BeginVertical();
            GUILayout.Label("Inspector", _skin.GetStyle("H1"));

            if (_selectedNode == null)
            {
                GUILayout.Label("Selected Node: None", _skin.GetStyle("H2"));
            }
            else
            {
                GUILayout.Label("Selected Node: " + _selectedNode.windowTitle, _skin.GetStyle("H2"));
                _selectedNode.DrawInspector();
            }

            GUILayout.EndVertical();
            GUILayout.EndArea();

            EditorZoomArea.Begin(_currentZoom,
                                 new Rect(inspectorRect.xMax, controlsArea.yMax, position.width - inspectorRect.width,
                                          position.height - controlsArea.height));

            foreach (var connection in _connections)
            {
                connection.Draw();
            }

            //if (_currentGraph != null)
            DrawWindows();

            ProcessNodeEvents(Event.current);

            EditorZoomArea.End();

            if (GUI.changed)
            {
                Repaint();
            }
        }
Exemple #19
0
    private void DrawZoomArea()
    {
        _bezierTexture = _bezierTexture ?? Resources.Load("Internal/1x2AA", typeof(Texture2D)) as Texture2D;


        EditorZoomArea.Begin(_zoom, _networkRect);
        {
            if (ActionEditor.instance != null && ActionEditor.instance.currentLibraryNetwork != null)
            {
                Handles.BeginGUI();
                {
                    Handles.color = Color.black;

                    int i = 0;

                    foreach (ActionConnection ac in ActionEditor.instance.currentLibraryNetwork.connections)
                    {
                        Vector2 toMiddle   = ac.To.drawPos.Middle();
                        Vector2 fromMiddle = ac.From.drawPos.Middle();

                        Vector2 arrow1Pos = 0.5f * toMiddle + 0.5f * fromMiddle - new Vector2(5.5f, 5f);
                        Vector2 arrow2Pos = 0.5f * toMiddle + 0.5f * fromMiddle - new Vector2(5.5f, 5f);

                        ActionSkill top    = ac.To.Position.Y > ac.From.Position.Y ? ac.From : ac.To;
                        ActionSkill bottom = ac.OtherEnd(top);

                        Vector3 start = new Vector3(top.drawPos.Middle().x, top.drawPos.Middle().y);
                        Vector3 end   = new Vector3(bottom.drawPos.Middle().x, bottom.drawPos.Middle().y);

                        if (i == selectedConnection)
                        {
                            Handles.DrawBezier(start,
                                               end,
                                               start,
                                               end,
                                               new Color(1, 0f, 0f, 1f),
                                               _bezierTexture,
                                               8f);
                        }

                        Handles.DrawBezier(start,
                                           end,
                                           start,
                                           end,
                                           new Color(1, 125f / 255f, 0f, 1f),
                                           _bezierTexture,
                                           6f);

                        Vector3 arrowDirection = new Vector3(toMiddle.x - fromMiddle.x, toMiddle.y - fromMiddle.y, 0f);

                        float arrowDirectionLength = arrowDirection.magnitude;

                        Handles.color = new Color(1f, 125f / 255f, 0f, 1f);

                        float angle1 = Mathf.Atan2(toMiddle.y - fromMiddle.y, toMiddle.x - fromMiddle.x);

                        Vector2 labelPos = RotatePoint(new Vector2(0, -25f), angle1);

                        Rect arrow1box = new Rect(arrow1Pos.x + 35f * arrowDirection.x / arrowDirectionLength + labelPos.x + 5f,
                                                  arrow1Pos.y + 35f * arrowDirection.y / arrowDirectionLength + labelPos.y + 5f, 7.5f + ac.fromValue.ToString().Length *7.5f, 18f);

                        arrow1box.center -= new Vector2(arrow1box.width / 2, arrow1box.height / 2);

                        Rect arrow2box = new Rect(arrow2Pos.x - 35f * arrowDirection.x / arrowDirectionLength - labelPos.x + 5f,
                                                  arrow2Pos.y - 35f * arrowDirection.y / arrowDirectionLength - labelPos.y + 5f, 7.5f + ac.toValue.ToString().Length *7.5f, 18f);

                        arrow2box.center -= new Vector2(arrow2box.width / 2, arrow2box.height / 2);

                        Vector3 toVect3 = new Vector3(arrow1Pos.x + 5f + 20f * arrowDirection.x / arrowDirectionLength, arrow1Pos.y + 5f + 20f * arrowDirection.y / arrowDirectionLength, -10f);

                        if (showNumbers)
                        {
                            if (ac.toValue != 0)
                            {
                                GUI.Label(arrow2box, ac.toValue.ToString(), GUI.skin.GetStyle("TextField"));

                                //Handles.ArrowCap(0,toVect3,Quaternion.LookRotation(-arrowDirection),60f);
                            }

                            //Vector3 fromVec3 = new Vector3(arrow2Pos.x + 5f - 20f*arrowDirection.x/arrowDirectionLength,arrow2Pos.y + 5f - 20f*arrowDirection.y/arrowDirectionLength,-10f);

                            if (ac.fromValue != 0)
                            {
                                GUI.Label(arrow1box, ac.fromValue.ToString(), GUI.skin.GetStyle("TextField"));
                                //Handles.ArrowCap(0,fromVec3,Quaternion.LookRotation(arrowDirection),60f);
                            }
                        }

                        if (showArrows)
                        {
                            if (ac.toValue != 0)
                            {
                                //GUI.Label(arrow2box,ac.toValue.ToString(),GUI.skin.GetStyle("TextField"));
                                if (Mathf.Approximately(arrowDirection.sqrMagnitude, 0f))
                                {
                                    Handles.ArrowCap(0, toVect3, Quaternion.identity, 60f);
                                }
                                else
                                {
                                    Handles.ArrowCap(0, toVect3, Quaternion.LookRotation(-arrowDirection), 60f);
                                }
                            }

                            Vector3 fromVec3 = new Vector3(arrow2Pos.x + 5f - 20f * arrowDirection.x / arrowDirectionLength, arrow2Pos.y + 5f - 20f * arrowDirection.y / arrowDirectionLength, -10f);

                            if (ac.fromValue != 0)
                            {
                                //GUI.Label(arrow1box,ac.fromValue.ToString (),GUI.skin.GetStyle("TextField"));
                                if (!Mathf.Approximately(arrowDirection.sqrMagnitude, 0f))
                                {
                                    Handles.ArrowCap(0, fromVec3, Quaternion.LookRotation(arrowDirection), 60f);
                                }
                                else
                                {
                                    Handles.ArrowCap(0, fromVec3, Quaternion.identity, 60f);
                                }
                            }
                        }

//						if(ac.toValue == 0 && ac.fromValue == 0)
//						{
//							connectionToRemove.Add(ac);
//						}

                        ++i;
                    }

                    if (isCreatingConnection && skillsToConnect.Count == 1)
                    {
                        Vector2 zoomMousePos = ConvertScreenCoordsToZoomCoords(new Vector2(_currentMousePosition.x, _currentMousePosition.y)) - new Vector2(offset.X, offset.Y);

                        Vector2 mouseDirection = skillsToConnect[0].drawPos.Middle() - zoomMousePos;

                        Handles.DrawBezier(new Vector3(skillsToConnect[0].drawPos.Middle().x, skillsToConnect[0].drawPos.Middle().y),
                                           new Vector3(zoomMousePos.x, zoomMousePos.y),
                                           new Vector3(skillsToConnect[0].drawPos.Middle().x - mouseDirection.x, skillsToConnect[0].drawPos.Middle().y - mouseDirection.y),
                                           new Vector3(zoomMousePos.x + mouseDirection.x, zoomMousePos.y + mouseDirection.y),
                                           new Color(1, 125f / 255f, 0f, 1f),
                                           _bezierTexture,
                                           6f);

                        this.Repaint();
                    }
                } Handles.EndGUI();


                if (ActionEditor.instance.currentLibraryNetwork.skills != null)
                {
                    int i = 0;

                    foreach (ActionSkill actSkill in ActionEditor.instance.currentLibraryNetwork.skills)
                    {
                        actSkill.Draw(selectedSkills.Contains(i), actSkill == skillBeingDrawn);

                        ++i;
                    }
                }
            }
        } EditorZoomArea.End();
    }
    private void OnGUI()
    {
        _zoomArea.height = position.height;
        _zoomArea.width  = position.width;

        ZoomedArea = EditorZoomArea.Begin(zoomScale, _zoomArea);

        DrawGrid(20, 0.2f, Color.gray);
        DrawGrid(100, 0.4f, Color.gray);

        DrawConnections();
        DrawNodes();

        DrawConnectionLine(Event.current);

        ProcessNodeEvents(Event.current);

        EditorZoomArea.End();

        ProcessEvents(Event.current);

        ChainName = EditorGUILayout.TextField("Progression Chain", ChainName);

        //expands the json data with another dream slot
        if (GUILayout.Button("New Progression Chain"))
        {
            //clar all nodes
            if (nodes != null)
            {
                nodes.Clear();
            }
            if (connections != null)
            {
                connections.Clear();
            }

            ProgressionData = new JsonData();
            ChainName       = "";
        }

        TextAsset LoadProgressionChain = EditorGUILayout.ObjectField(Resources.Load("Assets/Resources/Progress/" + ChainName), typeof(TextAsset), allowSceneObjects: true) as TextAsset;

        if (LoadProgressionChain != null)
        {
            var pro = TextParser.ToJson(LoadProgressionChain);

            if (pro != ProgressionData)
            {
                ChainName = LoadProgressionChain.name;
                LoadInfo(pro);
            }
        }

        //expands the json data with another dream slot
        if (GUILayout.Button("Save Progression Chain"))
        {
            if (ChainName != "")
            {
                SaveItemInfo();
            }
        }


        if (GUI.changed)
        {
            Repaint();
        }
    }
        private void HandleEvents()
        {
            Vector2 mousePos = Event.current.mousePosition;

            if (SceneLayoutRect.Contains(mousePos) && Event.current.type == EventType.ScrollWheel)
            {
                Vector2 delta          = Event.current.delta;
                Vector2 zoomedMousePos = (mousePos - SceneLayoutRect.min) / zoomScale + zoomOrigin;

                float oldZoomScale = zoomScale;

                float zoomDelta = -delta.y / 150.0f;
                zoomScale += zoomDelta;
                zoomScale  = Mathf.Clamp(zoomScale, 0.5f, 2.0f);

                zoomOrigin += (zoomedMousePos - zoomOrigin) - (oldZoomScale / zoomScale) * (zoomedMousePos - zoomOrigin);

                Event.current.Use();
            }

            if (Event.current.type == EventType.MouseDrag && Event.current.button == 2)
            {
                zoomDelta   = Event.current.delta;
                zoomDelta  /= zoomScale;
                zoomOrigin += zoomDelta;

                Event.current.Use();
            }
            else
            {
                zoomDelta = Vector2.zero;
            }            /**/
        }

        ToolbarContents AddToolbarItem(string path, Type BlockType, bool fix)
        {
            var pathLst = path.Split("/".ToCharArray());
            var node    = _root;

            for (int i = 0; i < pathLst.Length; ++i)
            {
                int idx = -1;
                for (int j = 0; j < node.subcontents.Count && idx == -1; ++j)
                {
                    if (node.subcontents[j].tooltip == pathLst[i])
                    {
                        idx = j;
                    }
                }

                if (idx != -1)
                {
                    node = node.subcontents[idx];
                }
                else
                {
                    Type t = null;
                    if (i == pathLst.Length - 1)
                    {
                        t = BlockType;
                    }
                    var n = new ToolbarContents(new GUIContent(pathLst[i]), t);
                    n.fix = fix;
                    node.subcontents.Add(n);
                    node = n;
                }
            }
            return(node);
        }

        void SortToolbarContents(ToolbarContents item)
        {
            for (int i = 0; i < item.subcontents.Count; ++i)
            {
                SortToolbarContents(item.subcontents[i]);
            }
            for (int i = 0; i < item.subcontents.Count; ++i)
            {
                if (item.subcontents [i].fix)
                {
                    continue;
                }
                for (int j = i + 1; j < item.subcontents.Count; ++j)
                {
                    if (!item.subcontents [j].fix &&
                        item.subcontents [j].subcontents.Count > item.subcontents [i].subcontents.Count)
                    {
                        var t = item.subcontents [j];
                        item.subcontents [j] = item.subcontents [i];
                        item.subcontents [i] = t;
                    }
                }
            }
        }

        int DrawToolbar(ToolbarContents item, Vector2 pos, float width, float itemHeight, ToolbarContents[] contents, int index, out ToolbarContents selected)
        {
            selected = null;
            width    = 30;
            for (int i = 0; i < contents.Length; ++i)
            {
                if (contents[i].image == null)
                {
                    width = Mathf.Max(width, GUI.skin.box.CalcSize(contents[i]).x + 10);
                }
            }
            Rect r          = new Rect(pos, new Vector2(width, itemHeight * contents.Length));
            var  scrollRect = new Rect(pos, new Vector2(width + 10, Mathf.Min(200, r.height)));

            // item.scroll=GUI.BeginScrollView(scrollRect, item.scroll, r,GUIStyle.none,GUI.skin.verticalScrollbar);
            GUI.Box(r, "");

            var ret = GUI.SelectionGrid(r, index, contents, 1);

            //GUI.EndScrollView();
            if (ret != -1)
            {
                if (contents[ret].subcontents.Count == 0)
                {
                    selected = contents[ret];
                }
            }
            if (index >= 0)
            {
                pos.x += width;
                if (contents[index].subcontents.Count > 0)
                {
                    pos.y += itemHeight * index - item.scroll.y;
                    contents[index].index = DrawToolbar(contents[index], pos, width, itemHeight, contents[index].subcontents.ToArray(), contents[index].index, out selected);
                }
            }

            return(ret);
        }

        void ClearToolbarSelection(ToolbarContents item)
        {
            if (item.index >= 0)
            {
                ClearToolbarSelection(item.subcontents[item.index]);
            }
            item.index = -1;
        }

        void DrawTools()
        {
            bool show = true;

            if (Event.current.type == EventType.mouseDown && Event.current.control)
            {
                _searchMenu     = true;
                _searchPosition = Event.current.mousePosition;
                Event.current.Use();
            }


            // zoomScale = EditorGUI.Slider(new Rect(100.0f, 0.0f, 200.0f, 25.0f), zoomScale, 0.5f,2.0f);

            if (_searchMenu)
            {
                //   GUILayout.BeginHorizontal();
                var pos = new Rect(_searchPosition, new Vector2(30, 20));
                GUI.Box(pos, "Find:");
                pos.x     += pos.width;
                pos.width  = 150;
                _inputText = GUI.TextField(pos, _inputText);
                pos.x     += pos.width;
                pos.width  = pos.height;
                if (GUI.Button(pos, "X"))
                {
                    _inputText = "";
                }
                // GUILayout.FlexibleSpace();
                //GUILayout.EndHorizontal();
                if (_inputText.Trim().Length > 0)
                {
                    var items = NodeFactory.FindItems(_inputText);
                    var skin  = GUI.skin.scrollView;
                    GUI.skin.scrollView = GUI.skin.box;
                    pos.x  = _searchPosition.x;
                    pos.y += pos.height;
                    float buttonHeight = 20;
                    float rectHeight   = buttonHeight * items.Count;
                    pos.height      = Mathf.Min(200, rectHeight);
                    pos.width       = 250;
                    _scrollPosition = GUI.BeginScrollView(pos, _scrollPosition, new Rect(pos.x, pos.y, pos.width - 10, rectHeight), GUIStyle.none, GUI.skin.verticalScrollbar);
                    if (items.Count > 0)
                    {
                        show = false;
                    }
                    Rect bRect = new Rect(pos.x, pos.y, pos.width - 10, buttonHeight);
                    foreach (var i in items)
                    {
                        if (GUI.Button(bRect, new GUIContent(i.item, i.item)))
                        {
                            if (i.type != null)
                            {
                                _graphGUI.CreateMenuItemCallback(i.type);
                            }
                            _searchMenu = false;
                            //_inputText = "";
                        }
                        bRect.y += bRect.height;
                    }
                    GUI.EndScrollView();
                    GUI.skin.scrollView = skin;
                }
            }
            if (show)
            {
                ToolbarContents selected = null;
                GUI.Box(new Rect(10, 50, 150, 20), "Available Blocks:");
                _root.index = DrawToolbar(_root, new Vector2(10, 70), 70, 25, _root.subcontents.ToArray(), _root.index, out selected);
                if (selected != null)
                {
                    if (selected.BlockType != null)
                    {
                        _graphGUI.CreateMenuItemCallback(selected.BlockType);
                    }
                    ClearToolbarSelection(_root);
                }
            }

            var e = Event.current;

            if (e.type == EventType.MouseDown && e.clickCount == 1)
            {
                _searchMenu = false;
                ClearToolbarSelection(_root);
            }
        }

        void OnGUI()
        {
            const float kBarHeight = 17;
            var         width      = position.width;
            var         height     = position.height;

            var evt = new Event(Event.current);

            // Synchronize the graph with the patch at this point.
            if (!_graph.isValid)
            {
                var a = Selection.activeGameObject;
                _graphGUI.PushSelection();
                _graph.SyncWithPatch();
                _graphGUI.PopSelection();
                Selection.activeGameObject = a;
            }

            // Show the placeholder if the patch is not available.
            if (!_graph.isValid)
            {
                DrawPlaceholderGUI();
                return;
            }



            SceneLayoutRect.width  = width;  // / zoomScale;
            SceneLayoutRect.height = height; /// zoomScale;
            HandleEvents();

            /*_zoomArea = new Rect (0-_zoomCoordsOrigin.x, 0-_zoomCoordsOrigin.y, width, height - kBarHeight);
             * // Main graph area*/
            EditorZoomArea.Begin(1, SceneLayoutRect);
            _graphGUI.BeginGraphGUI(this, new Rect(0, 0, width / zoomScale, height / zoomScale - kBarHeight));

            //Can draw group boxes here
            //GUI.Box (new Rect (50, 50, 500, 500), "Body");

            _graphGUI.OnGraphGUI();
            _graphGUI.EndGraphGUI();
            EditorZoomArea.End();
            var e = Event.current;

            Event.current = evt;
            DrawTools();
            Event.current = e;

            // Clear selection on background click
            if (e.type == EventType.MouseDown && e.clickCount == 1)
            {
                _graphGUI.ClearSelection();
            }


            //	if (_labelStyle == null)
            {
                _labelStyle = new GUIStyle(GUI.skin.GetStyle("Label"));
                _labelStyle.normal.textColor = Color.white;
                _labelStyle.alignment        = TextAnchor.MiddleCenter;
                _labelStyle.fontSize         = 14;
            }


            GUI.Label(new Rect(width - 320, height - 80, 300, 40), "Meta-Modeling Editor" /*"\nDeveloped by: MHD Yamen Saraiji"*/, _labelStyle);

            // Status bar
            GUILayout.BeginArea(new Rect(0, height - kBarHeight, width, kBarHeight));
            GUILayout.Label(_graph.patch.name);
            GUILayout.EndArea();
            //DrawNonZoomArea ();
        }