CornerSlider() static private method

static private CornerSlider ( int id, Vector3 cornerPos, Vector3 handleDir, Vector3 outwardsDir1, Vector3 outwardsDir2, float handleSize, Handles drawFunc, Vector2 snap ) : Vector3
id int
cornerPos Vector3
handleDir Vector3
outwardsDir1 Vector3
outwardsDir2 Vector3
handleSize float
drawFunc Handles
snap Vector2
return Vector3
        static Vector3 ResizeHandlesGUI(Rect rect, Vector3 pivot, Quaternion rotation, out Vector3 scalePivot)
        {
            if (Event.current.type == EventType.MouseDown)
            {
                s_StartRect = rect;
            }

            scalePivot = pivot;
            Vector3 scale = Vector3.one;

            Quaternion inverseRotation = Quaternion.Inverse(rotation);

            // Loop through the 8 handles (sides and corners) using a nested loop.
            // (The loop covers 9 combinations, but the center position is ignored.)
            for (int xHandle = 0; xHandle <= 2; xHandle++)
            {
                for (int yHandle = 0; yHandle <= 2; yHandle++)
                {
                    // Ignore center
                    if (xHandle == 1 && yHandle == 1)
                    {
                        continue;
                    }

                    Vector3 origPos = GetRectPointInWorld(s_StartRect, pivot, rotation, xHandle, yHandle);
                    Vector3 curPos  = GetRectPointInWorld(rect, pivot, rotation, xHandle, yHandle);

                    float size = 0.05f * HandleUtility.GetHandleSize(curPos);
                    int   id   = GUIUtility.GetControlID(s_ResizeHandlesHash, FocusType.Passive);
                    if (GUI.color.a > 0 || GUIUtility.hotControl == id)
                    {
                        EditorGUI.BeginChangeCheck();
                        Vector3 newPos;

                        EventType typeBefore = Event.current.type;

                        if (xHandle == 1 || yHandle == 1)
                        {
                            // Side resizer (1D)
                            Vector3 sideDir  = (xHandle == 1 ? rotation * Vector3.right * rect.width : rotation * Vector3.up * rect.height);
                            Vector3 slideDir = (xHandle == 1 ? rotation * Vector3.up : rotation * Vector3.right);
                            newPos = RectHandles.SideSlider(id, curPos, sideDir, slideDir, size, null, EditorSnapSettings.move);
                        }
                        else
                        {
                            // Corner handle (2D)
                            Vector3 outwardsA = rotation * Vector3.right * (xHandle - 1);
                            Vector3 outwardsB = rotation * Vector3.up * (yHandle - 1);
                            newPos = RectHandles.CornerSlider(id, curPos, rotation * Vector3.forward, outwardsA, outwardsB, size, RectHandles.RectScalingHandleCap, EditorSnapSettings.move);
                        }

                        // Calculate snapping values if applicable
                        bool supportsRectSnapping = Selection.transforms.Length == 1 &&
                                                    UnityEditorInternal.InternalEditorUtility.SupportsRectLayout(Selection.activeTransform) &&
                                                    Selection.activeTransform.parent.rotation == rotation;
                        if (supportsRectSnapping)
                        {
                            Transform     transform           = Selection.activeTransform;
                            RectTransform rectTransform       = transform.GetComponent <RectTransform>();
                            Transform     transformParent     = transform.parent;
                            RectTransform rectTransformParent = transformParent.GetComponent <RectTransform>();
                            if (typeBefore == EventType.MouseDown && Event.current.type != EventType.MouseDown)
                            {
                                RectTransformSnapping.CalculateOffsetSnapValues(transformParent, transform, rectTransformParent, rectTransform, xHandle, yHandle);
                            }
                        }

                        if (EditorGUI.EndChangeCheck())
                        {
                            // Resize handles require more fine grained rounding of values than other tools.
                            // With other tools, the slight rounding is not notizable as long as it's just sub-pixel,
                            // because the manipulated object is being moved at the same time.
                            // However, with resize handles, when dragging one edge or corner,
                            // the opposite is standing still, and even slight rounding can cause shaking/vibration.
                            // At a fraction of the normal rounding, the shaking is very unlikely to happen though.
                            ManipulationToolUtility.SetMinDragDifferenceForPos(curPos, 0.1f);

                            if (supportsRectSnapping)
                            {
                                Transform     transformParent = Selection.activeTransform.parent;
                                RectTransform rectParent      = transformParent.GetComponent <RectTransform>();

                                Vector2 snapSize = Vector2.one * HandleUtility.GetHandleSize(newPos) * RectTransformSnapping.kSnapThreshold;
                                snapSize.x /= (inverseRotation * transformParent.TransformVector(Vector3.right)).x;
                                snapSize.y /= (inverseRotation * transformParent.TransformVector(Vector3.up)).y;

                                Vector3 newPosInParent        = transformParent.InverseTransformPoint(newPos) - (Vector3)rectParent.rect.min;
                                Vector3 newPosInParentSnapped = (Vector3)RectTransformSnapping.SnapToGuides(newPosInParent, snapSize) + Vector3.forward * newPosInParent.z;
                                ManipulationToolUtility.DisableMinDragDifferenceBasedOnSnapping(newPosInParent, newPosInParentSnapped);
                                newPos = transformParent.TransformPoint(newPosInParentSnapped + (Vector3)rectParent.rect.min);
                            }

                            bool scaleFromPivot = Event.current.alt;
                            bool uniformScaling = Event.current.shift;

                            if (!scaleFromPivot)
                            {
                                scalePivot = GetRectPointInWorld(s_StartRect, pivot, rotation, 2 - xHandle, 2 - yHandle);
                            }

                            if (uniformScaling)
                            {
                                newPos = Vector3.Project(newPos - scalePivot, origPos - scalePivot) + scalePivot;
                            }

                            Vector3 sizeBefore = inverseRotation * (origPos - scalePivot);
                            Vector3 sizeAfter  = inverseRotation * (newPos - scalePivot);
                            if (xHandle != 1)
                            {
                                scale.x = sizeAfter.x / sizeBefore.x;
                            }
                            if (yHandle != 1)
                            {
                                scale.y = sizeAfter.y / sizeBefore.y;
                            }

                            if (uniformScaling)
                            {
                                float refScale = (xHandle == 1 ? scale.y : scale.x);
                                scale = Vector3.one * refScale;
                            }

                            if (uniformScaling)
                            {
                                float refScale = (xHandle == 1 ? scale.y : scale.x);
                                scale = Vector3.one * refScale;
                            }
                        }

                        if (xHandle == 0)
                        {
                            ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp(kChangingLeft, typeBefore);
                        }
                        if (xHandle == 2)
                        {
                            ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp(kChangingRight, typeBefore);
                        }
                        if (xHandle != 1)
                        {
                            ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp(kChangingWidth, typeBefore);
                        }
                        if (yHandle == 0)
                        {
                            ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp(kChangingBottom, typeBefore);
                        }
                        if (yHandle == 2)
                        {
                            ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp(kChangingTop, typeBefore);
                        }
                        if (yHandle != 1)
                        {
                            ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp(kChangingHeight, typeBefore);
                        }
                    }
                }
            }

            return(scale);
        }
Example #2
0
        private static Vector3 ResizeHandlesGUI(Rect rect, Vector3 pivot, Quaternion rotation, out Vector3 scalePivot)
        {
            if (Event.current.type == EventType.MouseDown)
            {
                s_StartRect = rect;
            }
            scalePivot = pivot;
            Vector3    one        = Vector3.one;
            Quaternion quaternion = Quaternion.Inverse(rotation);

            for (int i = 0; i <= 2; i++)
            {
                for (int j = 0; j <= 2; j++)
                {
                    if ((i != 1) || (j != 1))
                    {
                        Vector3 vector2   = GetRectPointInWorld(s_StartRect, pivot, rotation, i, j);
                        Vector3 position  = GetRectPointInWorld(rect, pivot, rotation, i, j);
                        float   size      = 0.05f * HandleUtility.GetHandleSize(position);
                        int     controlID = GUIUtility.GetControlID(s_ResizeHandlesHash, FocusType.Passive);
                        if ((GUI.color.a > 0f) || (GUIUtility.hotControl == controlID))
                        {
                            Vector3 vector4;
                            EditorGUI.BeginChangeCheck();
                            EventType typeBefore = Event.current.type;
                            if ((i == 1) || (j == 1))
                            {
                                Vector3 sideVector = (i != 1) ? ((Vector3)((rotation * Vector3.up) * rect.height)) : ((Vector3)((rotation * Vector3.right) * rect.width));
                                Vector3 direction  = (i != 1) ? ((Vector3)(rotation * Vector3.right)) : ((Vector3)(rotation * Vector3.up));
                                vector4 = RectHandles.SideSlider(controlID, position, sideVector, direction, size, null, 0f);
                            }
                            else
                            {
                                Vector3 vector7 = (Vector3)((rotation * Vector3.right) * (i - 1));
                                Vector3 vector8 = (Vector3)((rotation * Vector3.up) * (j - 1));
                                vector4 = RectHandles.CornerSlider(controlID, position, (Vector3)(rotation * Vector3.forward), vector7, vector8, size, new Handles.DrawCapFunction(RectHandles.RectScalingCap), Vector2.zero);
                            }
                            bool flag = ((Selection.transforms.Length == 1) && InternalEditorUtility.SupportsRectLayout(Selection.activeTransform)) && (Selection.activeTransform.parent.rotation == rotation);
                            if (flag)
                            {
                                Transform     activeTransform = Selection.activeTransform;
                                RectTransform component       = activeTransform.GetComponent <RectTransform>();
                                Transform     parent          = activeTransform.parent;
                                RectTransform parentRect      = parent.GetComponent <RectTransform>();
                                if ((typeBefore == EventType.MouseDown) && (Event.current.type != EventType.MouseDown))
                                {
                                    RectTransformSnapping.CalculateOffsetSnapValues(parent, activeTransform, parentRect, component, i, j);
                                }
                            }
                            if (EditorGUI.EndChangeCheck())
                            {
                                ManipulationToolUtility.SetMinDragDifferenceForPos(position);
                                if (flag)
                                {
                                    Transform     transform5   = Selection.activeTransform.parent;
                                    RectTransform transform6   = transform5.GetComponent <RectTransform>();
                                    Vector2       snapDistance = (Vector2)((Vector2.one * HandleUtility.GetHandleSize(vector4)) * 0.05f);
                                    Vector3       vector14     = (Vector3)(quaternion * transform5.TransformVector(Vector3.right));
                                    snapDistance.x /= vector14.x;
                                    Vector3 vector15 = (Vector3)(quaternion * transform5.TransformVector(Vector3.up));
                                    snapDistance.y /= vector15.y;
                                    Vector3 vector10 = transform5.InverseTransformPoint(vector4) - transform6.rect.min;
                                    Vector3 positionAfterSnapping = (Vector3)(RectTransformSnapping.SnapToGuides(vector10, snapDistance) + (Vector3.forward * vector10.z));
                                    ManipulationToolUtility.DisableMinDragDifferenceBasedOnSnapping(vector10, positionAfterSnapping);
                                    vector4 = transform5.TransformPoint(positionAfterSnapping + transform6.rect.min);
                                }
                                bool alt       = Event.current.alt;
                                bool actionKey = EditorGUI.actionKey;
                                bool flag4     = Event.current.shift && !actionKey;
                                if (!alt)
                                {
                                    scalePivot = GetRectPointInWorld(s_StartRect, pivot, rotation, 2 - i, 2 - j);
                                }
                                if (flag4)
                                {
                                    vector4 = Vector3.Project(vector4 - scalePivot, vector2 - scalePivot) + scalePivot;
                                }
                                Vector3 vector12 = (Vector3)(quaternion * (vector2 - scalePivot));
                                Vector3 vector13 = (Vector3)(quaternion * (vector4 - scalePivot));
                                if (i != 1)
                                {
                                    one.x = vector13.x / vector12.x;
                                }
                                if (j != 1)
                                {
                                    one.y = vector13.y / vector12.y;
                                }
                                if (flag4)
                                {
                                    float num5 = (i != 1) ? one.x : one.y;
                                    one = (Vector3)(Vector3.one * num5);
                                }
                                if (actionKey && (i == 1))
                                {
                                    if (Event.current.shift)
                                    {
                                        one.x = one.z = 1f / Mathf.Sqrt(Mathf.Max(one.y, 0.0001f));
                                    }
                                    else
                                    {
                                        one.x = 1f / Mathf.Max(one.y, 0.0001f);
                                    }
                                }
                                if (flag4)
                                {
                                    float num6 = (i != 1) ? one.x : one.y;
                                    one = (Vector3)(Vector3.one * num6);
                                }
                                if (actionKey && (i == 1))
                                {
                                    if (Event.current.shift)
                                    {
                                        one.x = one.z = 1f / Mathf.Sqrt(Mathf.Max(one.y, 0.0001f));
                                    }
                                    else
                                    {
                                        one.x = 1f / Mathf.Max(one.y, 0.0001f);
                                    }
                                }
                                if (actionKey && (j == 1))
                                {
                                    if (Event.current.shift)
                                    {
                                        one.y = one.z = 1f / Mathf.Sqrt(Mathf.Max(one.x, 0.0001f));
                                    }
                                    else
                                    {
                                        one.y = 1f / Mathf.Max(one.x, 0.0001f);
                                    }
                                }
                            }
                            switch (i)
                            {
                            case 0:
                                ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp("ChangingLeft", typeBefore);
                                break;

                            case 2:
                                ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp("ChangingRight", typeBefore);
                                break;
                            }
                            if (i != 1)
                            {
                                ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp("ChangingWidth", typeBefore);
                            }
                            if (j == 0)
                            {
                                ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp("ChangingBottom", typeBefore);
                            }
                            if (j == 2)
                            {
                                ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp("ChangingTop", typeBefore);
                            }
                            if (j != 1)
                            {
                                ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp("ChangingHeight", typeBefore);
                            }
                        }
                    }
                }
            }
            return(one);
        }
Example #3
0
        private static Vector3 ResizeHandlesGUI(Rect rect, Vector3 pivot, Quaternion rotation, out Vector3 scalePivot)
        {
            if (Event.current.type == EventType.MouseDown)
            {
                RectTool.s_StartRect = rect;
            }
            scalePivot = pivot;
            Vector3    result    = Vector3.one;
            Quaternion rotation2 = Quaternion.Inverse(rotation);

            for (int i = 0; i <= 2; i++)
            {
                for (int j = 0; j <= 2; j++)
                {
                    if (i != 1 || j != 1)
                    {
                        Vector3 rectPointInWorld  = RectTool.GetRectPointInWorld(RectTool.s_StartRect, pivot, rotation, i, j);
                        Vector3 rectPointInWorld2 = RectTool.GetRectPointInWorld(rect, pivot, rotation, i, j);
                        float   num       = 0.05f * HandleUtility.GetHandleSize(rectPointInWorld2);
                        int     controlID = GUIUtility.GetControlID(RectTool.s_ResizeHandlesHash, FocusType.Passive);
                        if (GUI.color.a > 0f || GUIUtility.hotControl == controlID)
                        {
                            EditorGUI.BeginChangeCheck();
                            EventType type = Event.current.type;
                            Vector3   vector;
                            if (i == 1 || j == 1)
                            {
                                Vector3 sideVector = (i != 1) ? (rotation * Vector3.up * rect.height) : (rotation * Vector3.right * rect.width);
                                Vector3 direction  = (i != 1) ? (rotation * Vector3.right) : (rotation * Vector3.up);
                                vector = RectHandles.SideSlider(controlID, rectPointInWorld2, sideVector, direction, num, null, 0f);
                            }
                            else
                            {
                                Vector3 vector2   = rotation * Vector3.right * (float)(i - 1);
                                Vector3 vector3   = rotation * Vector3.up * (float)(j - 1);
                                int     arg_1AB_0 = controlID;
                                Vector3 arg_1AB_1 = rectPointInWorld2;
                                Vector3 arg_1AB_2 = rotation * Vector3.forward;
                                Vector3 arg_1AB_3 = vector2;
                                Vector3 arg_1AB_4 = vector3;
                                float   arg_1AB_5 = num;
                                if (RectTool.< > f__mg$cache0 == null)
                                {
                                    RectTool.< > f__mg$cache0 = new Handles.CapFunction(RectHandles.RectScalingHandleCap);
                                }
                                vector = RectHandles.CornerSlider(arg_1AB_0, arg_1AB_1, arg_1AB_2, arg_1AB_3, arg_1AB_4, arg_1AB_5, RectTool.< > f__mg$cache0, Vector2.zero);
                            }
                            bool flag = Selection.transforms.Length == 1 && InternalEditorUtility.SupportsRectLayout(Selection.activeTransform) && Selection.activeTransform.parent.rotation == rotation;
                            if (flag)
                            {
                                Transform     activeTransform = Selection.activeTransform;
                                RectTransform component       = activeTransform.GetComponent <RectTransform>();
                                Transform     parent          = activeTransform.parent;
                                RectTransform component2      = parent.GetComponent <RectTransform>();
                                if (type == EventType.MouseDown && Event.current.type != EventType.MouseDown)
                                {
                                    RectTransformSnapping.CalculateOffsetSnapValues(parent, activeTransform, component2, component, i, j);
                                }
                            }
                            if (EditorGUI.EndChangeCheck())
                            {
                                ManipulationToolUtility.SetMinDragDifferenceForPos(rectPointInWorld2, 0.1f);
                                if (flag)
                                {
                                    Transform     parent2      = Selection.activeTransform.parent;
                                    RectTransform component3   = parent2.GetComponent <RectTransform>();
                                    Vector2       snapDistance = Vector2.one * HandleUtility.GetHandleSize(vector) * 0.05f;
                                    snapDistance.x /= (rotation2 * parent2.TransformVector(Vector3.right)).x;
                                    snapDistance.y /= (rotation2 * parent2.TransformVector(Vector3.up)).y;
                                    Vector3 vector4 = parent2.InverseTransformPoint(vector) - component3.rect.min;
                                    Vector3 vector5 = RectTransformSnapping.SnapToGuides(vector4, snapDistance) + Vector3.forward * vector4.z;
                                    ManipulationToolUtility.DisableMinDragDifferenceBasedOnSnapping(vector4, vector5);
                                    vector = parent2.TransformPoint(vector5 + component3.rect.min);
                                }
                                bool alt       = Event.current.alt;
                                bool actionKey = EditorGUI.actionKey;
                                bool flag2     = Event.current.shift && !actionKey;
                                if (!alt)
                                {
                                    scalePivot = RectTool.GetRectPointInWorld(RectTool.s_StartRect, pivot, rotation, 2 - i, 2 - j);
                                }
                                if (flag2)
                                {
                                    vector = Vector3.Project(vector - scalePivot, rectPointInWorld - scalePivot) + scalePivot;
                                }
                                Vector3 vector6 = rotation2 * (rectPointInWorld - scalePivot);
                                Vector3 vector7 = rotation2 * (vector - scalePivot);
                                if (i != 1)
                                {
                                    result.x = vector7.x / vector6.x;
                                }
                                if (j != 1)
                                {
                                    result.y = vector7.y / vector6.y;
                                }
                                if (flag2)
                                {
                                    float d = (i != 1) ? result.x : result.y;
                                    result = Vector3.one * d;
                                }
                                if (actionKey && i == 1)
                                {
                                    if (Event.current.shift)
                                    {
                                        result.x = (result.z = 1f / Mathf.Sqrt(Mathf.Max(result.y, 0.0001f)));
                                    }
                                    else
                                    {
                                        result.x = 1f / Mathf.Max(result.y, 0.0001f);
                                    }
                                }
                                if (flag2)
                                {
                                    float d2 = (i != 1) ? result.x : result.y;
                                    result = Vector3.one * d2;
                                }
                                if (actionKey && i == 1)
                                {
                                    if (Event.current.shift)
                                    {
                                        result.x = (result.z = 1f / Mathf.Sqrt(Mathf.Max(result.y, 0.0001f)));
                                    }
                                    else
                                    {
                                        result.x = 1f / Mathf.Max(result.y, 0.0001f);
                                    }
                                }
                                if (actionKey && j == 1)
                                {
                                    if (Event.current.shift)
                                    {
                                        result.y = (result.z = 1f / Mathf.Sqrt(Mathf.Max(result.x, 0.0001f)));
                                    }
                                    else
                                    {
                                        result.y = 1f / Mathf.Max(result.x, 0.0001f);
                                    }
                                }
                            }
                            if (i == 0)
                            {
                                ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp("ChangingLeft", type);
                            }
                            if (i == 2)
                            {
                                ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp("ChangingRight", type);
                            }
                            if (i != 1)
                            {
                                ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp("ChangingWidth", type);
                            }
                            if (j == 0)
                            {
                                ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp("ChangingBottom", type);
                            }
                            if (j == 2)
                            {
                                ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp("ChangingTop", type);
                            }
                            if (j != 1)
                            {
                                ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp("ChangingHeight", type);
                            }
                        }
                    }
                }
            }
            return(result);
        }
Example #4
0
        private static Vector3 ResizeHandlesGUI(Rect rect, Vector3 pivot, Quaternion rotation, out Vector3 scalePivot)
        {
            if (Event.current.type == EventType.MouseDown)
            {
                RectTool.s_StartRect = rect;
            }
            scalePivot = pivot;
            Vector3    vector3_1  = Vector3.one;
            Quaternion quaternion = Quaternion.Inverse(rotation);

            for (int xHandle = 0; xHandle <= 2; ++xHandle)
            {
                for (int yHandle = 0; yHandle <= 2; ++yHandle)
                {
                    if (xHandle != 1 || yHandle != 1)
                    {
                        Vector3 rectPointInWorld1 = RectTool.GetRectPointInWorld(RectTool.s_StartRect, pivot, rotation, xHandle, yHandle);
                        Vector3 rectPointInWorld2 = RectTool.GetRectPointInWorld(rect, pivot, rotation, xHandle, yHandle);
                        float   num       = 0.05f * HandleUtility.GetHandleSize(rectPointInWorld2);
                        int     controlId = GUIUtility.GetControlID(RectTool.s_ResizeHandlesHash, FocusType.Passive);
                        if ((double)GUI.color.a > 0.0 || GUIUtility.hotControl == controlId)
                        {
                            EditorGUI.BeginChangeCheck();
                            EventType type = Event.current.type;
                            Vector3   position;
                            if (xHandle == 1 || yHandle == 1)
                            {
                                Vector3 sideVector = xHandle != 1 ? rotation * Vector3.up * rect.height : rotation * Vector3.right * rect.width;
                                Vector3 direction  = xHandle != 1 ? rotation * Vector3.right : rotation * Vector3.up;
                                position = RectHandles.SideSlider(controlId, rectPointInWorld2, sideVector, direction, num, (Handles.DrawCapFunction)null, 0.0f);
                            }
                            else
                            {
                                Vector3 outwardsDir1 = rotation * Vector3.right * (float)(xHandle - 1);
                                Vector3 outwardsDir2 = rotation * Vector3.up * (float)(yHandle - 1);
                                position = RectHandles.CornerSlider(controlId, rectPointInWorld2, rotation * Vector3.forward, outwardsDir1, outwardsDir2, num, new Handles.DrawCapFunction(RectHandles.RectScalingCap), Vector2.zero);
                            }
                            bool flag1 = Selection.transforms.Length == 1 && InternalEditorUtility.SupportsRectLayout(Selection.activeTransform) && Selection.activeTransform.parent.rotation == rotation;
                            if (flag1)
                            {
                                Transform     activeTransform = Selection.activeTransform;
                                RectTransform component1      = activeTransform.GetComponent <RectTransform>();
                                Transform     parent          = activeTransform.parent;
                                RectTransform component2      = parent.GetComponent <RectTransform>();
                                if (type == EventType.MouseDown && Event.current.type != EventType.MouseDown)
                                {
                                    RectTransformSnapping.CalculateOffsetSnapValues(parent, activeTransform, component2, component1, xHandle, yHandle);
                                }
                            }
                            if (EditorGUI.EndChangeCheck())
                            {
                                ManipulationToolUtility.SetMinDragDifferenceForPos(rectPointInWorld2);
                                if (flag1)
                                {
                                    Transform     parent       = Selection.activeTransform.parent;
                                    RectTransform component    = parent.GetComponent <RectTransform>();
                                    Vector2       snapDistance = Vector2.one * HandleUtility.GetHandleSize(position) * 0.05f;
                                    snapDistance.x /= (quaternion * parent.TransformVector(Vector3.right)).x;
                                    snapDistance.y /= (quaternion * parent.TransformVector(Vector3.up)).y;
                                    Vector3 positionBeforeSnapping = parent.InverseTransformPoint(position) - (Vector3)component.rect.min;
                                    Vector3 positionAfterSnapping  = (Vector3)RectTransformSnapping.SnapToGuides((Vector2)positionBeforeSnapping, snapDistance) + Vector3.forward * positionBeforeSnapping.z;
                                    ManipulationToolUtility.DisableMinDragDifferenceBasedOnSnapping(positionBeforeSnapping, positionAfterSnapping);
                                    position = parent.TransformPoint(positionAfterSnapping + (Vector3)component.rect.min);
                                }
                                bool alt       = Event.current.alt;
                                bool actionKey = EditorGUI.actionKey;
                                bool flag2     = Event.current.shift && !actionKey;
                                if (!alt)
                                {
                                    scalePivot = RectTool.GetRectPointInWorld(RectTool.s_StartRect, pivot, rotation, 2 - xHandle, 2 - yHandle);
                                }
                                if (flag2)
                                {
                                    position = Vector3.Project(position - scalePivot, rectPointInWorld1 - scalePivot) + scalePivot;
                                }
                                Vector3 vector3_2 = quaternion * (rectPointInWorld1 - scalePivot);
                                Vector3 vector3_3 = quaternion * (position - scalePivot);
                                if (xHandle != 1)
                                {
                                    vector3_1.x = vector3_3.x / vector3_2.x;
                                }
                                if (yHandle != 1)
                                {
                                    vector3_1.y = vector3_3.y / vector3_2.y;
                                }
                                if (flag2)
                                {
                                    vector3_1 = Vector3.one * (xHandle != 1 ? vector3_1.x : vector3_1.y);
                                }
                                if (actionKey && xHandle == 1)
                                {
                                    vector3_1.x = !Event.current.shift ? 1f / Mathf.Max(vector3_1.y, 0.0001f) : (vector3_1.z = 1f / Mathf.Sqrt(Mathf.Max(vector3_1.y, 0.0001f)));
                                }
                                if (flag2)
                                {
                                    vector3_1 = Vector3.one * (xHandle != 1 ? vector3_1.x : vector3_1.y);
                                }
                                if (actionKey && xHandle == 1)
                                {
                                    vector3_1.x = !Event.current.shift ? 1f / Mathf.Max(vector3_1.y, 0.0001f) : (vector3_1.z = 1f / Mathf.Sqrt(Mathf.Max(vector3_1.y, 0.0001f)));
                                }
                                if (actionKey && yHandle == 1)
                                {
                                    vector3_1.y = !Event.current.shift ? 1f / Mathf.Max(vector3_1.x, 0.0001f) : (vector3_1.z = 1f / Mathf.Sqrt(Mathf.Max(vector3_1.x, 0.0001f)));
                                }
                            }
                            if (xHandle == 0)
                            {
                                ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp("ChangingLeft", type);
                            }
                            if (xHandle == 2)
                            {
                                ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp("ChangingRight", type);
                            }
                            if (xHandle != 1)
                            {
                                ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp("ChangingWidth", type);
                            }
                            if (yHandle == 0)
                            {
                                ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp("ChangingBottom", type);
                            }
                            if (yHandle == 2)
                            {
                                ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp("ChangingTop", type);
                            }
                            if (yHandle != 1)
                            {
                                ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp("ChangingHeight", type);
                            }
                        }
                    }
                }
            }
            return(vector3_1);
        }