EndLines() публичный статический Метод

public static EndLines ( ) : void
Результат void
        internal static Rect RectCreator(float textureWidth, float textureHeight, GUIStyle rectStyle)
        {
            Event   current       = Event.current;
            Vector2 mousePosition = current.mousePosition;
            int     controlID     = s_RectSelectionID;
            Rect    rect          = new Rect();

            switch (current.GetTypeForControl(controlID))
            {
            case EventType.MouseDown:
                if (current.button == 0)
                {
                    GUIUtility.hotControl = controlID;
                    Rect    rect2   = new Rect(0f, 0f, textureWidth, textureHeight);
                    Vector2 vector2 = Handles.s_InverseMatrix.MultiplyPoint((Vector3)mousePosition);
                    float   a       = Mathf.Max(vector2.x, rect2.xMin);
                    vector2.x = Mathf.Min(a, rect2.xMax);
                    float introduced9 = Mathf.Max(vector2.y, rect2.yMin);
                    vector2.y = Mathf.Min(introduced9, rect2.yMax);
                    s_DragStartScreenPosition = Handles.s_Matrix.MultiplyPoint((Vector3)vector2);
                    s_CurrentMousePosition    = mousePosition;
                    current.Use();
                }
                return(rect);

            case EventType.MouseUp:
                if ((GUIUtility.hotControl == controlID) && (current.button == 0))
                {
                    if (ValidRect(s_DragStartScreenPosition, s_CurrentMousePosition))
                    {
                        rect        = GetCurrentRect(false, textureWidth, textureHeight, s_DragStartScreenPosition, s_CurrentMousePosition);
                        GUI.changed = true;
                        current.Use();
                    }
                    GUIUtility.hotControl = 0;
                }
                return(rect);

            case EventType.MouseMove:
            case EventType.KeyUp:
            case EventType.ScrollWheel:
                return(rect);

            case EventType.MouseDrag:
                if (GUIUtility.hotControl == controlID)
                {
                    s_CurrentMousePosition = new Vector2(mousePosition.x, mousePosition.y);
                    current.Use();
                }
                return(rect);

            case EventType.KeyDown:
                if ((GUIUtility.hotControl == controlID) && (current.keyCode == KeyCode.Escape))
                {
                    GUIUtility.hotControl = 0;
                    GUI.changed           = true;
                    current.Use();
                }
                return(rect);

            case EventType.Repaint:
                if ((GUIUtility.hotControl == controlID) && ValidRect(s_DragStartScreenPosition, s_CurrentMousePosition))
                {
                    SpriteEditorUtility.BeginLines((Color)(Color.green * 1.5f));
                    SpriteEditorUtility.DrawBox(GetCurrentRect(false, textureWidth, textureHeight, s_DragStartScreenPosition, s_CurrentMousePosition));
                    SpriteEditorUtility.EndLines();
                }
                return(rect);
            }
            return(rect);
        }
Пример #2
0
        internal static Rect RectCreator(float textureWidth, float textureHeight, GUIStyle rectStyle)
        {
            Event   current       = Event.current;
            Vector2 mousePosition = current.mousePosition;
            int     num           = SpriteEditorHandles.s_RectSelectionID;
            Rect    result        = default(Rect);

            switch (current.GetTypeForControl(num))
            {
            case EventType.MouseDown:
                if (current.button == 0)
                {
                    GUIUtility.hotControl = num;
                    Rect    rect = new Rect(0f, 0f, textureWidth, textureHeight);
                    Vector2 v    = Handles.s_InverseMatrix.MultiplyPoint(mousePosition);
                    v.x = Mathf.Min(Mathf.Max(v.x, rect.xMin), rect.xMax);
                    v.y = Mathf.Min(Mathf.Max(v.y, rect.yMin), rect.yMax);
                    SpriteEditorHandles.s_DragStartScreenPosition = Handles.s_Matrix.MultiplyPoint(v);
                    SpriteEditorHandles.s_CurrentMousePosition    = mousePosition;
                    current.Use();
                }
                break;

            case EventType.MouseUp:
                if (GUIUtility.hotControl == num && current.button == 0)
                {
                    if (SpriteEditorHandles.ValidRect(SpriteEditorHandles.s_DragStartScreenPosition, SpriteEditorHandles.s_CurrentMousePosition))
                    {
                        result      = SpriteEditorHandles.GetCurrentRect(false, textureWidth, textureHeight, SpriteEditorHandles.s_DragStartScreenPosition, SpriteEditorHandles.s_CurrentMousePosition);
                        GUI.changed = true;
                        current.Use();
                    }
                    GUIUtility.hotControl = 0;
                }
                break;

            case EventType.MouseDrag:
                if (GUIUtility.hotControl == num)
                {
                    SpriteEditorHandles.s_CurrentMousePosition = new Vector2(mousePosition.x, mousePosition.y);
                    current.Use();
                }
                break;

            case EventType.KeyDown:
                if (GUIUtility.hotControl == num && current.keyCode == KeyCode.Escape)
                {
                    GUIUtility.hotControl = 0;
                    GUI.changed           = true;
                    current.Use();
                }
                break;

            case EventType.Repaint:
                if (GUIUtility.hotControl == num && SpriteEditorHandles.ValidRect(SpriteEditorHandles.s_DragStartScreenPosition, SpriteEditorHandles.s_CurrentMousePosition))
                {
                    SpriteEditorUtility.BeginLines(Color.green * 1.5f);
                    SpriteEditorUtility.DrawBox(SpriteEditorHandles.GetCurrentRect(false, textureWidth, textureHeight, SpriteEditorHandles.s_DragStartScreenPosition, SpriteEditorHandles.s_CurrentMousePosition));
                    SpriteEditorUtility.EndLines();
                }
                break;
            }
            return(result);
        }
        static internal Rect RectCreator(Rect textureArea, GUIStyle rectStyle)
        {
            Event   evt      = Event.current;
            Vector2 mousePos = evt.mousePosition;
            int     id       = s_RectSelectionID;
            Rect    result   = new Rect();

            switch (evt.GetTypeForControl(id))
            {
            case EventType.MouseDown:
                if (evt.button == 0)
                {
                    GUIUtility.hotControl = id;

                    // Make sure that the starting position is clamped to inside texture area
                    Vector2 point = Handles.inverseMatrix.MultiplyPoint(mousePos);

                    point.x = Mathf.Min(Mathf.Max(point.x, textureArea.xMin), textureArea.xMax);
                    point.y = Mathf.Min(Mathf.Max(point.y, textureArea.yMin), textureArea.yMax);

                    // Save clamped starting position for later use
                    s_DragStartScreenPosition = Handles.matrix.MultiplyPoint(point);

                    // Actual position
                    s_CurrentMousePosition = mousePos;

                    evt.Use();
                }
                break;

            case EventType.MouseDrag:
                if (GUIUtility.hotControl == id)
                {
                    s_CurrentMousePosition = new Vector2(mousePos.x, mousePos.y);
                    evt.Use();
                }
                break;

            case EventType.Repaint:
                if (GUIUtility.hotControl == id && ValidRect(s_DragStartScreenPosition, s_CurrentMousePosition))
                {
                    // TODO: use rectstyle
                    //rectStyle.Draw (GetCurrentRect (true, textureWidth, textureHeight, s_DragStartScreenPosition, s_CurrentMousePosition), GUIContent.none, false, false, false, false);
                    SpriteEditorUtility.BeginLines(Color.green * 1.5f);
                    SpriteEditorUtility.DrawBox(GetCurrentRect(false, textureArea, s_DragStartScreenPosition, s_CurrentMousePosition));
                    SpriteEditorUtility.EndLines();
                }
                break;

            case EventType.MouseUp:
                if (GUIUtility.hotControl == id && evt.button == 0)
                {
                    if (ValidRect(s_DragStartScreenPosition, s_CurrentMousePosition))
                    {
                        result      = GetCurrentRect(false, textureArea, s_DragStartScreenPosition, s_CurrentMousePosition);
                        GUI.changed = true;
                        evt.Use();
                    }

                    GUIUtility.hotControl = 0;
                }
                break;

            case EventType.KeyDown:
                if (GUIUtility.hotControl == id)
                {
                    if (evt.keyCode == KeyCode.Escape)
                    {
                        GUIUtility.hotControl = 0;
                        GUI.changed           = true;
                        evt.Use();
                    }
                }
                break;
            }
            return(result);
        }