-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEasyPrimeTween.cs
69 lines (53 loc) · 1.46 KB
/
EasyPrimeTween.cs
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
namespace Game.Runtime.EasyPrimeTweens
{
using Interfaces;
using PrimeTween;
using Sirenix.OdinInspector;
using UnityEngine;
public class EasyPrimeTween : MonoBehaviour, IEasyPrimeTween
{
[SerializeField, BoxGroup("Settings")]
private bool playOnEnable;
[SerializeReference]
public ITween tween;
public Tween Tween => tween.Tween;
public Tween BackwardTween => tween.BackwardTween;
public void OnEnable()
{
if(playOnEnable)
Play();
}
public void Play()
{
if (tween.BackwardTween.isAlive)
tween.BackwardTween.Stop();
if (tween.Tween.isAlive) return;
tween.Play();
}
public void Backwards()
{
if (tween.Tween.isAlive)
tween.Tween.Stop();
if (tween.BackwardTween.isAlive) return;
tween.Backward();
}
public void Stop()
{
if (tween.Tween.isAlive)
tween.Tween.Stop();
if (tween.BackwardTween.isAlive)
tween.BackwardTween.Stop();
}
public void Reset()
{
Stop();
tween.Reset();
}
public void Restart()
{
Reset();
Play();
}
private void OnDisable() => Stop();
}
}