-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMyTweenColor.cs
More file actions
75 lines (65 loc) · 2.03 KB
/
Copy pathMyTweenColor.cs
File metadata and controls
75 lines (65 loc) · 2.03 KB
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
71
72
73
74
75
using UnityEngine;
using DG.Tweening;
using MyBox;
using TMPro;
using UnityEngine.UI;
namespace MTWrapper
{
public enum TextureType
{
Sprite, ImageUI, TextMeshProGUI
}
public class MyTweenColor : MyTween
{
public TextureType textureType;
[ConditionalField(nameof(textureType),false, TextureType.ImageUI)]
public Image imageToTween;
[ConditionalField(nameof(textureType),false, TextureType.Sprite)]
public SpriteRenderer spriteToTween;
[ConditionalField(nameof(textureType),false, TextureType.TextMeshProGUI)]
public TextMeshProUGUI textMeshProUGUI;
public ColorReference endColor;
private Tween _myTween;
private void Start()
{
if(onStart)
PlayForward();
}
public override Tween BuildTween()
{
switch (textureType)
{
case TextureType.Sprite:
_myTween = spriteToTween.DOColor(endColor.Value, duration);
break;
case TextureType.ImageUI:
_myTween = imageToTween.DOColor(endColor.Value, duration);
break;
case TextureType.TextMeshProGUI:
_myTween = textMeshProUGUI.DOColor(endColor.Value, duration);
break;
}
if (loop)
_myTween.SetLoops(loopCounts, loopType);
_myTween.SetAutoKill(autoKill);
return _myTween;
}
public override void PlayForward()
{
if (_myTween == null)
BuildTween();
_myTween.PlayForward();
}
public void PlayBackward()
{
if (_myTween == null)
BuildTween();
_myTween.PlayBackwards();
}
public override void Pause()
{
_myTween?.Pause();
}
public override Tween GetMyTween() { return _myTween; }
}
}