-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCountDownAnim.cs
59 lines (50 loc) · 1.58 KB
/
CountDownAnim.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class CountDownAnim : MonoBehaviour
{
[SerializeField] private TextMeshProUGUI text;
[SerializeField] private float scaleTime;
[SerializeField] private AnimationCurve scaleCurve;
[SerializeField] private GameObject hint;
[SerializeField] private float hintTime;
[SerializeField] private AnimationCurve hintCurve;
// Start is called before the first frame update
void Start()
{
StartCoroutine(CountDown());
}
int counter = 3;
bool animate;
private IEnumerator CountDown()
{
hint.SetActive(true);
text.text = counter.ToString();
LeanTween.scale(text.gameObject, new Vector3(1.5f, 1.5f, 1), scaleTime).setEase(scaleCurve);
animate = true;
if (animate)
{
LeanTween.moveLocalX(hint, 0, hintTime).setEase(hintCurve);
animate = false;
}
yield return new WaitForSeconds(1);
counter--;
if (counter > 0 && counter < 3)
{
StartCoroutine(CountDown());
}
if (counter <= 0)
{
LeanTween.scale(text.gameObject, new Vector3(1.5f, 1.5f, 1), scaleTime).setEase(scaleCurve);
text.text = "START";
LeanTween.moveLocalX(hint, -1000, hintTime).setEase(hintCurve);
yield return new WaitForSeconds(1);
LeanTween.moveLocalY(this.gameObject, -1000f, 4f).setEase(hintCurve);
}
}
// Update is called once per frame
void Update()
{
}
}