예제 #1
0
    public void Draw(Rect rect, EditorClip clip, EditorClipMaker maker)
    {
        float x = 0;

        if (mDrag)
        {
            x = rect.width * m_DragTriggerTime;
        }
        else
        {
            x = rect.width * m_TriggerTime;
        }

        position = new Rect(rect.x + x - WidthNode / 2, rect.y, WidthNode, maker.heightTrack);

        EditorGUI.DrawRect(position, maker.GetColorSet(this.name));

        if (Event.current.type == EventType.MouseDown && Event.current.button == 1 && position.Contains(Event.current.mousePosition))
        {
            // Now create the menu, add items and show it
            GenericMenu menu = new GenericMenu();
            menu.AddItem(new GUIContent("Copy Event"), false, EventMeauCopyClipEvent);
            menu.AddSeparator("");
            menu.AddItem(new GUIContent("Delete Event"), false, (e) => { EventMeauDeleteClipEvent(clip, maker); }, null);
            menu.ShowAsContext();
            Event.current.Use();
        }
        else
        {
            if (Event.current.type == EventType.MouseDown && Event.current.button == 0)
            {
                if (position.Contains(Event.current.mousePosition))
                {
                    mDrag             = true;
                    m_DragTriggerTime = rect.width * triggerTime;
                    maker.SetSelectClip(clip);
                    maker.SetSelectClipEvent(this);
                    maker.SetSelectListClipEvent(clip, this);
                    maker.SetClickOpera(this);
                    maker.Repaint();
                    Event.current.Use();
                }
            }
            else if (Event.current.type == EventType.MouseUp)
            {
                if (mDrag == true && m_DragTriggerTime != m_TriggerTime)
                {
                    this.BeginChange();
                    m_TriggerTime = m_DragTriggerTime;
                    this.EndChange();
                    maker.MarkModified();
                }
                mDrag = false;
            }
            if (mDrag)
            {
                float dragDetlaPos = Mathf.Clamp(Event.current.mousePosition.x, rect.x, rect.x + rect.width) - rect.x;
                dragDetlaPos = Mathf.Clamp(dragDetlaPos, 0, rect.width);
                float newtrigger = Mathf.Max(dragDetlaPos / rect.width, 0);
                if (Mathf.Abs(newtrigger - m_DragTriggerTime) > Deadzoom)
                {
                    m_DragTriggerTime = (float)System.Math.Round(newtrigger, 2);
                    maker.SetSelectListClipEvent(clip, this);
                    maker.Repaint();
//					maker.MarkChange ();
//					colorFrame = frameColorselected;
                }
            }
            else
            {
//				colorFrame = getFrameColor(editorAAClip.Target);
            }
        }
    }
예제 #2
0
    public void Draw(Rect rect, EditorClipMaker maker)
    {
        GUI.color           = Color.white;
        GUI.contentColor    = Color.white;
        GUI.backgroundColor = Color.white;

        this.position = rect;

        Rect rectHead     = new Rect(0, rect.y, maker.titleWidth, maker.heightTrack);
        Rect rectHeadText = new Rect(rectHead.x, rectHead.y, rectHead.width, rectHead.height);
        Rect rectBg       = new Rect(rect.x, rect.y, rect.width + maker.widthHead / 2, rect.height);

        Rect rectTrack = new Rect(maker.titleWidth, rect.y, rect.width - maker.titleWidth, maker.heightTrack);

        GUI.Box(rectBg, "");

        EditorGUI.DrawRect(rectHead, new Color(1, 1f, 1, 0.1f));

        int fontSize = GUI.skin.label.fontSize;

        GUI.skin.label.fontSize = 16;
        GUI.Label(rectHeadText, this.name);
        GUI.skin.label.fontSize = fontSize;

        //GUI.skin.textArea.alignment = TextAnchor.MiddleCenter;
        //string valname = GUI.TextArea (rectHeadText, this.name);
        //GUI.skin.textArea.alignment = TextAnchor.UpperLeft;

//		EditorGUI.DrawRect (rectBg, new Color (0, 0.4f, 1, 0.1f));



        for (int k = 0; k < ListClipEvent.Count; k++)
        {
            ListClipEvent [k].Draw(rectTrack, this, maker);
        }

        //if (GUI.changed) {
        //	this.name = valname;
        //}

        if (Event.current.type == EventType.MouseDown)
        {
            if (rectTrack.Contains(Event.current.mousePosition))
            {
                if (Event.current.button == 1)
                {
                    GenericMenu menu = new GenericMenu();
                    float       rate = getRateBaseMousePosition(rectTrack, Event.current.mousePosition);
                    GenericMenu.MenuFunction2 callAddNode = delegate(object userData) {
                        MeauEventAddClipEvent(rate, maker);
                    };
                    menu.AddItem(new GUIContent("Add Event"), false, callAddNode, maker);
                    if (EditorClipEvent.CloneInstance != null)
                    {
                        GenericMenu.MenuFunction2 callPareseNode = delegate(object userData) {
                            MeauEventParseClipEvent(rate, maker);
                        };
                        menu.AddItem(new GUIContent("Parse Event"), false, callPareseNode, maker);
                    }
                    menu.AddItem(new GUIContent("Clear Event"), false, MeauEventClearClipEvent, maker);

                    if (maker.ListClip.Count >= 2)
                    {
                        menu.AddSeparator("");
                        menu.AddItem(new GUIContent("Move Up"), false, MeauEventMoveUpClip, maker);
                        menu.AddItem(new GUIContent("Move Down"), false, MeauEventMoveDownClip, maker);
                    }
                    menu.AddSeparator("");

                    menu.AddItem(new GUIContent("Copy Track"), false, EventMeauCopyClip, maker);
                    menu.AddItem(new GUIContent("Delete Track"), false, EventMeauDeleteClip, maker);

                    // Now create the menu, add items and show it
                    if (menu != null)
                    {
                        menu.ShowAsContext();
                    }
                }
                else if (Event.current.button == 0)
                {
                    maker.SetSelectListClipEvent(this, null);
                    maker.SetSelectClipEvent(null);
                    maker.SetSelectClip(this);
                    maker.SetClickOpera(this);
                }
                Event.current.Use();
            }
        }
    }