public void DoTimeControl(Rect rect)
{
if (s_Styles == null)
{
s_Styles = new Styles();
}
Event current = Event.current;
int controlID = GUIUtility.GetControlID(kScrubberIDHash, FocusType.Keyboard);
Rect position = rect;
position.height = 21f;
Rect rect3 = position;
rect3.xMin += 33f;
switch (current.GetTypeForControl(controlID))
{
case EventType.MouseDown:
if (rect.Contains(current.mousePosition))
{
GUIUtility.keyboardControl = controlID;
}
if (rect3.Contains(current.mousePosition))
{
EditorGUIUtility.SetWantsMouseJumping(1);
GUIUtility.hotControl = controlID;
this.m_MouseDrag = current.mousePosition.x - rect3.xMin;
this.nextCurrentTime = ((this.m_MouseDrag * (this.stopTime - this.startTime)) / rect3.width) + this.startTime;
this.m_WrapForwardDrag = false;
current.Use();
}
goto Label_02C7;
case EventType.MouseUp:
if (GUIUtility.hotControl == controlID)
{
EditorGUIUtility.SetWantsMouseJumping(0);
GUIUtility.hotControl = 0;
current.Use();
}
goto Label_02C7;
case EventType.MouseDrag:
if (GUIUtility.hotControl != controlID)
{
goto Label_02C7;
}
this.m_MouseDrag += current.delta.x * this.playbackSpeed;
if (!this.loop || (((this.m_MouseDrag >= 0f) || !this.m_WrapForwardDrag) && (this.m_MouseDrag <= rect3.width)))
{
goto Label_01E0;
}
if (this.m_MouseDrag <= rect3.width)
{
if (this.m_MouseDrag < 0f)
{
this.currentTime += this.stopTime - this.startTime;
}
break;
}
this.currentTime -= this.stopTime - this.startTime;
break;
case EventType.KeyDown:
if (GUIUtility.keyboardControl == controlID)
{
if (current.keyCode == KeyCode.LeftArrow)
{
if ((this.currentTime - this.startTime) > 0.01f)
{
this.deltaTime = -0.01f;
}
current.Use();
}
if (current.keyCode == KeyCode.RightArrow)
{
if ((this.stopTime - this.currentTime) > 0.01f)
{
this.deltaTime = 0.01f;
}
current.Use();
}
}
goto Label_02C7;
default:
goto Label_02C7;
}
this.m_WrapForwardDrag = true;
this.m_MouseDrag = Mathf.Repeat(this.m_MouseDrag, rect3.width);
Label_01E0:
this.nextCurrentTime = ((Mathf.Clamp(this.m_MouseDrag, 0f, rect3.width) * (this.stopTime - this.startTime)) / rect3.width) + this.startTime;
current.Use();
Label_02C7:
GUI.Box(position, GUIContent.none, s_Styles.timeScrubber);
this.playing = GUI.Toggle(position, this.playing, !this.playing ? s_Styles.playIcon : s_Styles.pauseIcon, s_Styles.playButton);
float x = Mathf.Lerp(rect3.x, rect3.xMax, this.normalizedTime);
if (GUIUtility.keyboardControl == controlID)
{
Handles.color = new Color(1f, 0f, 0f, 1f);
}
else
{
Handles.color = new Color(1f, 0f, 0f, 0.5f);
}
Handles.DrawLine((Vector3) new Vector2(x, rect3.yMin), (Vector3) new Vector2(x, rect3.yMax));
Handles.DrawLine((Vector3) new Vector2(x + 1f, rect3.yMin), (Vector3) new Vector2(x + 1f, rect3.yMax));
}