blob: 69b91f7460db3f95e8b0d20df423759fcde4a123 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace TweenAnimation
{
public class PlaybackTimer
{
// 考虑了Pause的playback时间,没考虑playback limit
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;
}
}
}
|