diff options
author | chai <chaifix@163.com> | 2021-05-30 11:05:38 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-05-30 11:05:38 +0800 |
commit | 3bd21c73384906267a2a4c48acdb96df77bd1f67 (patch) | |
tree | 5f55740506d64f4bcc6fe0bc32b9a26c5e6da8b6 /Assets/UI_Extension/Scripts/Animation/Tween/Editor/PlaybackTimer.cs | |
parent | 26e4dc3a35d9c778684388de1af8b3f288fe627d (diff) |
*tween
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 |