void LinksGUI()
 {
     if (currentGraph != null && currentGraph.links != null)
     {
         foreach (AG_NodeLink link in currentGraph.links)
         {
             GLDraw.DrawConnectingCurve(link.beginningPoint.imageRect.center, link.endingPoint.imageRect.center, Color.blue, 1.3f);
         }
     }
 }
Exemple #2
0
    private Vector2 DrawRoot(TreeNode node, Vector2 offset, bool isRuning, RunStatus?state, out Vector2 current)
    {
        var             tempOffset = new Vector2(offset.x + offsetx + width, offset.y);
        float           offex      = tempOffset.x;
        var             expand     = this [node.guid];
        List <LineData> points     = new List <LineData> ();

        if (expand.Expanded)
        {
            for (var i = 0; i < node.childs.Count; i++)
            {
                if (node.childs [i] == currentDrag)
                {
                    continue;
                }
                RunStatus?cRunstate;
                var       runing = CheckRunning(node.childs [i].guid, out cRunstate);
                var       mine   = tempOffset;
                var       or     = DrawRoot(node.childs [i], tempOffset, runing, cRunstate, out mine);
                var       h      = Mathf.Max(height + offsety, or.y);
                offex = Mathf.Max(offex, or.x);

                points.Add(new LineData {
                    point = new Vector2(mine.x, mine.y + 5), IsRunning = runing
                });
                tempOffset.y += h;
            }
        }
        var t             = Mathf.Max(0, (tempOffset.y - offset.y - height));
        int currentHeight = height;

        if (this [node.guid].OnEdited)
        {
            currentHeight = editHeight;
            runstate      = GetComposite(node.guid);
            //runNodeName = node.ToString();
        }
        var rect = new Rect(offset.x, offset.y + (t / 2), width, currentHeight);

        this[node.guid] = DrawNode(rect, node, expand, node.childs.Count > 0, isRuning, state);

        foreach (var p in points)
        {
            GLDraw.DrawConnectingCurve(new Vector2(rect.xMax + 10, rect.center.y), p.point,
                                       p.IsRunning? Color.yellow: Color.black, p.IsRunning?2:1);
        }

        current = rect.position;

        return(new Vector2(offex, Mathf.Max(height + offsety, t + offsety + currentHeight)));
    }
Exemple #3
0
    private void OnGUI()
    {
        Repaint();
        //GetPlayingInfo ();
        Color color = Color.black;
        float lS    = 230;

        DrawOp();


        if (data == null)
        {
            return;
        }

        _scroll = GUI.BeginScrollView(new Rect(0, 0, position.width - lS, position.height), _scroll, view);

        var currentView = new Rect(_scroll.x, _scroll.y, position.width - lS, position.height);

        BeginWindows();
        var offsetX   = 50;
        var offsetY   = 10;
        var sizeX     = 200;
        var sizeY     = 60;
        var sizeYBase = 100;

        Vector2 cOffset = new Vector2(offsetX + sizeX + offsetX, offsetY);

        Vector2            eOffset   = new Vector2(cOffset.x + sizeX + offsetX, offsetY);
        float              maxY      = 0;
        int                indexC    = 100;
        List <TargetPoint> cEndPoint = new List <TargetPoint> ();

        foreach (var i in data.Containers)
        {
            int indexE       = indexC * 100;;
            var oldOffset    = eOffset;
            var listEndPoint = new List <Vector2> ();
            foreach (var e in i.effectGroup)
            {
                var eRect = new Rect(eOffset, new Vector2(sizeX, sizeY));
                if (Event.current.type == UnityEngine.EventType.ContextClick)
                {
                    if (eRect.Contains(Event.current.mousePosition))
                    {
                        GenericMenu m = new GenericMenu();
                        m.AddItem(new GUIContent("Delete"), false, DeleteEffectGroupDe,
                                  new DeleteEffectGroup {
                            egroup = e, Container = i
                        });
                        m.AddSeparator("");
                        m.AddItem(new GUIContent("Edit Effects"), false, ShowEffectGroup, e);
                        m.ShowAsContext();
                        Event.current.Use();
                    }
                }
                if (DrawWindow(indexE, eRect, EffectWindow, e.key))
                {
                    ShowObject(e);
                }

                listEndPoint.Add(new Vector2(eOffset.x, eOffset.y + 5));
                eOffset = new Vector2(eOffset.x, eOffset.y + offsetY + sizeY);
                indexE++;
            }

            var center = oldOffset.y + ((eOffset.y - oldOffset.y) / 2);
            if (maxY < center)
            {
                maxY = center;
            }
            var cRect = new Rect(new Vector2(cOffset.x, maxY), new Vector2(sizeX, sizeY));


            if (DrawWindow(indexC, cRect,
                           EventWindow, i.type.ToString()))
            {
                ShowObject(i);
            }

            if (IsRuning(i.type))
            {
                cEndPoint.Add(new TargetPoint(Color.yellow, new Vector2(cOffset.x, maxY + 5), 2));
                GLDraw.DrawBox(cRect, Color.yellow, 2);
            }
            else
            {
                cEndPoint.Add(new TargetPoint(color, new Vector2(cOffset.x, maxY + 5), 1));
            }


            if (Event.current.type == UnityEngine.EventType.ContextClick)
            {
                if (cRect.Contains(Event.current.mousePosition))
                {
                    GenericMenu m = new GenericMenu();
                    m.AddItem(new GUIContent("Delete"), false, DeleteEvent, i);
                    m.AddSeparator("");
                    m.AddItem(new GUIContent("Add Effect Group"), false, AddEffectGroup, i);
                    if (!string.IsNullOrEmpty(i.layoutPath))
                    {
                        m.AddItem(new GUIContent("Open Layout Editor"), false, OpenLayout, i);
                    }
                    m.ShowAsContext();
                    Event.current.Use();
                }
            }
            var start = new Vector2(cOffset.x + sizeX, maxY + sizeY / 2);
            foreach (var p in listEndPoint)
            {
                if (currentView.Contains(start) && currentView.Contains(p))
                {
                    GLDraw.DrawConnectingCurve(start, p, color, 1);
                }
            }
            maxY += offsetY + sizeY;
            indexC++;
        }


        var rectBase = new  Rect(new Vector2(offsetX, offsetY + maxY / 2), new Vector2(sizeX, sizeYBase));

        if (Event.current.type == UnityEngine.EventType.ContextClick)
        {
            if (rectBase.Contains(Event.current.mousePosition))
            {
                GenericMenu m = new GenericMenu();
                m.AddItem(new GUIContent("Add Event"), false, AddEvent, data);
                m.AddSeparator("");
                m.AddItem(new GUIContent("Save"), false, Save, data);
                m.AddItem(new GUIContent("Save As"), false, SaveAs, data);
                m.ShowAsContext();
                Event.current.Use();
            }
        }

        if (DrawWindow(0,
                       rectBase,
                       MagicWindow, data.name))
        {
            ShowObject(data);
        }
        // content



        var startBase = new Vector2(offsetX + sizeX, offsetY + maxY / 2 + sizeYBase / 2);

        foreach (var p in cEndPoint)
        {
            if (currentView.Contains(startBase) && currentView.Contains(p.point))
            {
                GLDraw.DrawConnectingCurve(startBase, p.point, p.color, p.withd);
            }
        }

        EndWindows();
        GUI.EndScrollView();



        view = new Rect(0, 0, eOffset.x + sizeX + offsetX, Mathf.Max(maxY, eOffset.y));

        var view2P = new Rect(position.width - lS, 0, lS, position.height);

        GUILayout.BeginArea(view2P);
        GUILayout.BeginVertical(GUILayout.Width(lS - 10));
        GUILayout.Label("Property");
        scrollProperty = GUILayout.BeginScrollView(scrollProperty);
        GUILayout.BeginVertical();
        if (currentObj != null)
        {
            PropertyDrawer.DrawObject(currentObj);
        }
        GUILayout.EndVertical();
        GUILayout.EndScrollView();
        GUILayout.EndVertical();
        GUILayout.EndArea();

        GLDraw.DrawLine(new Vector2(position.width - lS, 0),
                        new Vector2(position.width - lS, position.height), color, 1);
    }