blob: 7b1523f01c702bd943ad85ce182649dfd3d08ae8 (
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
|
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);
}
}
}
}
|