Beispiel #1
0
 public bool IsVisible(Vector2 position)
 {
     return(VisibleArea.Contains(position));
 }
        private void ContentGUI()
        {
            GUILayout.BeginArea(HierarchyArea);
            {
                if (UnityEngine.Event.current.type == EventType.ScrollWheel)
                {
                    ScrollInfo.currentScroll.x += UnityEngine.Event.current.delta.x;
                    ScrollInfo.currentScroll.y += 2 * UnityEngine.Event.current.delta.y;
                    float widthOfContent = ScrubArea.x + (CurrentSequence.Duration / ZoomInfo.meaningOfEveryMarker * ZoomInfo.currentXMarkerDist);
                    ScrollInfo.currentScroll.x = Mathf.Clamp(ScrollInfo.currentScroll.x, 0, widthOfContent);
                    UpdateCachedMarkerInformation();
                    UnityEngine.Event.current.Use();
                }
                GUILayout.BeginVertical();

                GUILayout.Box("", USEditorUtility.ContentBackground, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
                if (UnityEngine.Event.current.type == EventType.Repaint)
                {
                    if (VisibleArea != GUILayoutUtility.GetLastRect())
                    {
                        VisibleArea = GUILayoutUtility.GetLastRect();
                        SequenceWindow.Repaint();
                    }
                }
                GUILayout.BeginArea(VisibleArea);

                GUILayout.BeginScrollView(ScrollInfo.currentScroll, GUIStyle.none, GUIStyle.none);

                GUILayout.BeginVertical();

                DrawSideBarAndTimeLines();

                GUILayout.EndVertical();
                if (UnityEngine.Event.current.type == EventType.Repaint)
                {
                    if (TotalArea != GUILayoutUtility.GetLastRect())
                    {
                        TotalArea = GUILayoutUtility.GetLastRect();
                        SequenceWindow.Repaint();
                    }
                }
                GUILayout.EndScrollView();

                GUILayout.EndArea();

                //  SelectionArea = VisibleArea;
                if (VisibleArea.Contains(UnityEngine.Event.current.mousePosition) || UnityEngine.Event.current.rawType == EventType.MouseUp || UnityEngine.Event.current.rawType == EventType.MouseDrag)
                {
                    HandleEvent(UnityEngine.Event.current.rawType == EventType.MouseUp ? UnityEngine.Event.current.rawType : UnityEngine.Event.current.type, UnityEngine.Event.current.button, UnityEngine.Event.current.mousePosition);
                }

                // Render our mouse drag box.
                if (IsBoxSelecting && HasStartedDrag)
                {
                    Vector2 mousePosition = UnityEngine.Event.current.mousePosition;
                    Vector2 origin        = DragStartPosition;
                    Vector2 destination   = mousePosition;

                    if (mousePosition.x < DragStartPosition.x)
                    {
                        origin.x      = mousePosition.x;
                        destination.x = DragStartPosition.x;
                    }

                    if (mousePosition.y < DragStartPosition.y)
                    {
                        origin.y      = mousePosition.y;
                        destination.y = DragStartPosition.y;
                    }

                    Vector2 mouseDelta = destination - origin;
                    SelectionArea = new Rect(origin.x, origin.y, mouseDelta.x, mouseDelta.y);
                    if (!EditorGUIUtility.isProSkin)
                    {
                        GUI.Box(SelectionArea, "", USEditorUtility.USeqSkin.box);
                    }
                    else
                    {
                        GUI.Box(SelectionArea, "");
                    }

                    SequenceWindow.Repaint();
                }
            }
            GUILayout.EndVertical();
            GUILayout.EndArea();
        }