Liberi
An exergame built for kids with CP!
GUIGameCountDown.cs
1 using UnityEngine;
2 using UnityEngine.UI;
3 using System.Collections;
4 
9 public class GUIGameCountDown : MonoBehaviour
10 {
11  public Sprite[] CountDownSprites;
12  public Color[] SpriteColors;
13 
14  static GUIGameCountDown _instance;
15  static int _tickAnimParam = Animator.StringToHash("Tick");
16  Animator _animator;
17  Image _image;
18 
19  void Awake()
20  {
21  _instance = this;
22  _animator = GetComponentInChildren<Animator>();
23  _image = GetComponentInChildren<Image>();
24  }
25 
30  public static void Display(int num)
31  {
32  int clampedNum = Mathf.Clamp(num, 0, 3);
33 
34  _instance._image.color = _instance.SpriteColors[clampedNum];
35  _instance._image.sprite = _instance.CountDownSprites[clampedNum];
36  _instance._image.SetNativeSize();
37  _instance._animator.SetTrigger(_tickAnimParam);
38  }
39 }
static void Display(int num)
Displays the specified number playing the animted GUI popup for it. The number will be clamped in the...
A visual representation for pre minigame count downs. Displaying values 1 to 3 show the number...