using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEditor; namespace TweenAnimation { public partial class TweenAnimationInspector : Editor { bool m_MouseDown; DragState m_DragState; enum DragState { Release, Drag, } void DragPlay(Rect rulerRect) { if (!m_Pause) return; Event e = Event.current; Vector2 mousePos = e.mousePosition; bool bIn = rulerRect.Contains(mousePos); switch (m_DragState) { case DragState.Release: if (e.type == EventType.MouseDown && bIn) m_DragState = DragState.Drag; break; case DragState.Drag: if (e.type == EventType.MouseUp) m_DragState = DragState.Release; break; } if (m_DragState == DragState.Drag && bIn) { float x = mousePos.x - rulerRect.x; float t = x / rulerRect.width * animation.duration; float t0 = animation.GetIdentifiedTime(playbackTime); float dt = 0; if (t0 >= 0) dt = t - t0; else // pingpong dt = -t0 - t; m_PlaybackTimer.SetPauseTimeOffset(dt); } } } }