private Vector2 Slider2D(Rect rect, Vector2 value, Vector2 maxvalue, Vector2 minvalue, GUIStyle backStyle, GUIStyle thumbStyle)
{
if (backStyle != null)
{
if (thumbStyle == null)
{
return value;
}
int controlID = GUIUtility.GetControlID(s_Slider2Dhash, FocusType.Native);
if (maxvalue.x < minvalue.x)
{
swap(ref maxvalue.x, ref minvalue.x);
}
if (maxvalue.y < minvalue.y)
{
swap(ref maxvalue.y, ref minvalue.y);
}
float height = (thumbStyle.fixedHeight != 0f) ? thumbStyle.fixedHeight : ((float) thumbStyle.padding.vertical);
float width = (thumbStyle.fixedWidth != 0f) ? thumbStyle.fixedWidth : ((float) thumbStyle.padding.horizontal);
Vector2 vector = new Vector2(((rect.width - (backStyle.padding.right + backStyle.padding.left)) - (width * 2f)) / (maxvalue.x - minvalue.x), ((rect.height - (backStyle.padding.top + backStyle.padding.bottom)) - (height * 2f)) / (maxvalue.y - minvalue.y));
Rect position = new Rect((((rect.x + (value.x * vector.x)) + (width / 2f)) + backStyle.padding.left) - (minvalue.x * vector.x), (((rect.y + (value.y * vector.y)) + (height / 2f)) + backStyle.padding.top) - (minvalue.y * vector.y), width, height);
Event current = Event.current;
switch (current.GetTypeForControl(controlID))
{
case EventType.MouseDown:
if (rect.Contains(current.mousePosition))
{
GUIUtility.hotControl = controlID;
GUIUtility.keyboardControl = 0;
value.x = ((((current.mousePosition.x - rect.x) - width) - backStyle.padding.left) / vector.x) + minvalue.x;
value.y = ((((current.mousePosition.y - rect.y) - height) - backStyle.padding.top) / vector.y) + minvalue.y;
GUI.changed = true;
Event.current.Use();
}
return value;
case EventType.MouseUp:
if (GUIUtility.hotControl == controlID)
{
GUIUtility.hotControl = 0;
current.Use();
}
return value;
case EventType.MouseMove:
case EventType.KeyDown:
case EventType.KeyUp:
case EventType.ScrollWheel:
return value;
case EventType.MouseDrag:
if (GUIUtility.hotControl == controlID)
{
value.x = ((((current.mousePosition.x - rect.x) - width) - backStyle.padding.left) / vector.x) + minvalue.x;
value.y = ((((current.mousePosition.y - rect.y) - height) - backStyle.padding.top) / vector.y) + minvalue.y;
value.x = Mathf.Clamp(value.x, minvalue.x, maxvalue.x);
value.y = Mathf.Clamp(value.y, minvalue.y, maxvalue.y);
GUI.changed = true;
Event.current.Use();
return value;
}
return value;
case EventType.Repaint:
{
backStyle.Draw(rect, GUIContent.none, controlID);
Color color = GUI.color;
bool flag = ColorPicker.color.grayscale > 0.5f;
if (flag)
{
GUI.color = Color.black;
}
thumbStyle.Draw(position, GUIContent.none, controlID);
if (flag)
{
GUI.color = color;
}
return value;
}
}
}
return value;
}