diff options
Diffstat (limited to 'Assets/UI_Extension/Scripts/Animation/Tween/Editor/PlaybackTimer.cs')
-rw-r--r-- | Assets/UI_Extension/Scripts/Animation/Tween/Editor/PlaybackTimer.cs | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/Assets/UI_Extension/Scripts/Animation/Tween/Editor/PlaybackTimer.cs b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/PlaybackTimer.cs new file mode 100644 index 0000000..4890f2b --- /dev/null +++ b/Assets/UI_Extension/Scripts/Animation/Tween/Editor/PlaybackTimer.cs @@ -0,0 +1,70 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +namespace TweenAnimation +{ + public class PlaybackTimer + { + // 考虑了Pause的playback时间 + public float time + { + get + { + if (m_PauseRealTime != -1) + return m_PauseRealTime - m_StartRealTime; + return realTime; + } + } + + // 从调用Resume开始后的时间 + private float realTime + { + get + { + return (float)EditorApplication.timeSinceStartup - m_StartRealTime; + } + } + + private float m_StartRealTime; + + private float m_PauseRealTime; + + public PlaybackTimer() + { + Reset(); + } + + //Start & Resume + public void Resume() + { + if (m_PauseRealTime != -1) + m_StartRealTime = (float)EditorApplication.timeSinceStartup - time; + else + m_StartRealTime = (float)EditorApplication.timeSinceStartup; + m_PauseRealTime = -1; + } + + public void Pause() + { + m_PauseRealTime = (float)EditorApplication.timeSinceStartup; + } + + public void Stop() + { + Reset(); + } + + public void Reset() + { + m_StartRealTime = -1; + m_PauseRealTime = -1; + } + + public void SetPauseTimeOffset(float dt) + { + m_PauseRealTime += dt; + } + + } +}
\ No newline at end of file |