private static Vector3 MoveHandlesGUI(Rect rect, Vector3 pivot, Quaternion rotation)
{
bool flag2;
int controlID = GUIUtility.GetControlID(s_MoveHandleHash, FocusType.Passive);
Vector3 position = pivot;
float radius = HandleUtility.GetHandleSize(pivot) * 0.2f;
float num3 = 1f - GUI.color.a;
Vector3[] worldPoints = new Vector3[] { (rotation * new Vector2(rect.x, rect.y)) + pivot, (rotation * new Vector2(rect.xMax, rect.y)) + pivot, (rotation * new Vector2(rect.xMax, rect.yMax)) + pivot, (rotation * new Vector2(rect.x, rect.yMax)) + pivot };
VertexSnapping.HandleKeyAndMouseMove(controlID);
bool flag = ((Selection.transforms.Length == 1) && InternalEditorUtility.SupportsRectLayout(Selection.activeTransform)) && (Selection.activeTransform.parent.rotation == rotation);
Event current = Event.current;
EventType typeForControl = current.GetTypeForControl(controlID);
Plane plane = new Plane(worldPoints[0], worldPoints[1], worldPoints[2]);
switch (typeForControl)
{
case EventType.MouseDown:
flag2 = false;
if (!Tools.vertexDragging)
{
flag2 = (((current.button == 0) && (current.modifiers == EventModifiers.None)) && RectHandles.RaycastGUIPointToWorldHit(current.mousePosition, plane, out s_StartMouseWorldPos)) && ((SceneViewDistanceToRectangle(worldPoints, current.mousePosition) == 0f) || ((num3 > 0f) && (SceneViewDistanceToDisc(pivot, (Vector3) (rotation * Vector3.forward), radius, current.mousePosition) == 0f)));
break;
}
flag2 = true;
break;
case EventType.MouseUp:
if (GUIUtility.hotControl == controlID)
{
if (!s_Moving)
{
Selection.activeGameObject = SceneViewPicking.PickGameObject(current.mousePosition);
}
GUIUtility.hotControl = 0;
EditorGUIUtility.SetWantsMouseJumping(0);
HandleUtility.ignoreRaySnapObjects = null;
current.Use();
}
goto Label_0620;
case EventType.MouseDrag:
if (GUIUtility.hotControl == controlID)
{
s_CurrentMousePos += current.delta;
if (!s_Moving)
{
Vector2 vector2 = s_CurrentMousePos - s_StartMousePos;
if (vector2.magnitude > 3f)
{
s_Moving = true;
RectHandles.RaycastGUIPointToWorldHit(s_CurrentMousePos, plane, out s_StartMouseWorldPos);
}
}
if (s_Moving)
{
if (!Tools.vertexDragging)
{
Vector3 vector4;
ManipulationToolUtility.SetMinDragDifferenceForPos(pivot);
if (RectHandles.RaycastGUIPointToWorldHit(s_CurrentMousePos, plane, out vector4))
{
Vector3 vector = vector4 - s_StartMouseWorldPos;
if (current.shift)
{
vector = (Vector3) (Quaternion.Inverse(rotation) * vector);
if (s_LockAxis == -1)
{
float introduced28 = Mathf.Abs(vector.x);
s_LockAxis = (introduced28 <= Mathf.Abs(vector.y)) ? 1 : 0;
}
vector[1 - s_LockAxis] = 0f;
vector = (Vector3) (rotation * vector);
}
else
{
s_LockAxis = -1;
}
if (flag)
{
Transform parent = Selection.activeTransform.parent;
Vector3 vector6 = s_StartRectPosition + parent.InverseTransformVector(vector);
vector6.z = 0f;
Quaternion quaternion = Quaternion.Inverse(rotation);
Vector2 snapDistance = (Vector2) ((Vector2.one * HandleUtility.GetHandleSize(position)) * 0.05f);
Vector3 vector8 = (Vector3) (quaternion * parent.TransformVector(Vector3.right));
snapDistance.x /= vector8.x;
Vector3 vector9 = (Vector3) (quaternion * parent.TransformVector(Vector3.up));
snapDistance.y /= vector9.y;
Vector3 positionAfterSnapping = (Vector3) RectTransformSnapping.SnapToGuides(vector6, snapDistance);
ManipulationToolUtility.DisableMinDragDifferenceBasedOnSnapping(vector6, positionAfterSnapping);
vector = parent.TransformVector(positionAfterSnapping - s_StartRectPosition);
}
position = s_StartPosition + vector;
GUI.changed = true;
}
}
else
{
Vector3 vector3;
if (HandleUtility.ignoreRaySnapObjects == null)
{
Handles.SetupIgnoreRaySnapObjects();
}
if (HandleUtility.FindNearestVertex(s_CurrentMousePos, null, out vector3))
{
position = vector3;
GUI.changed = true;
}
ManipulationToolUtility.minDragDifference = (Vector3) Vector2.zero;
}
}
current.Use();
}
goto Label_0620;
case EventType.Repaint:
if (!Tools.vertexDragging)
{
Handles.color = Handles.secondaryColor * new Color(1f, 1f, 1f, 1.5f * num3);
Handles.CircleCap(controlID, pivot, rotation, radius);
Handles.color = Handles.secondaryColor * new Color(1f, 1f, 1f, 0.3f * num3);
Handles.DrawSolidDisc(pivot, (Vector3) (rotation * Vector3.forward), radius);
}
else
{
RectHandles.RectScalingHandleCap(controlID, pivot, rotation, 1f, EventType.Repaint);
}
goto Label_0620;
default:
goto Label_0620;
}
if (flag2)
{
s_StartPosition = pivot;
s_StartMousePos = s_CurrentMousePos = current.mousePosition;
s_Moving = false;
s_LockAxis = -1;
int num4 = controlID;
GUIUtility.keyboardControl = num4;
GUIUtility.hotControl = num4;
EditorGUIUtility.SetWantsMouseJumping(1);
HandleUtility.ignoreRaySnapObjects = null;
current.Use();
if (flag)
{
Transform activeTransform = Selection.activeTransform;
RectTransform component = activeTransform.GetComponent<RectTransform>();
Transform parentSpace = activeTransform.parent;
RectTransform parentRect = parentSpace.GetComponent<RectTransform>();
s_StartRectPosition = (Vector3) component.anchoredPosition;
RectTransformSnapping.CalculatePositionSnapValues(parentSpace, activeTransform, parentRect, component);
}
}
Label_0620:
ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp("ChangingPosX", typeForControl);
ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp("ChangingLeft", typeForControl);
ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp("ChangingRight", typeForControl);
ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp("ChangingPosY", typeForControl);
ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp("ChangingTop", typeForControl);
ManipulationToolUtility.DetectDraggingBasedOnMouseDownUp("ChangingBottom", typeForControl);
return position;
}