| | 1 | | using System.Collections; |
| | 2 | | using UnityEngine; |
| | 3 | | using UnityEngine.UI; |
| | 4 | |
|
| | 5 | | //Note (Adrian): This class is temporary and will dissapear when the new UI is implemented |
| | 6 | | public class CircleLoadingAnimator : MonoBehaviour |
| | 7 | | { |
| 0 | 8 | | public float animSpeed = 6f; |
| | 9 | |
|
| | 10 | | Image fillImage; |
| | 11 | | Coroutine coroutine; |
| | 12 | |
|
| | 13 | | private void OnEnable() |
| | 14 | | { |
| 0 | 15 | | if (fillImage == null) |
| 0 | 16 | | fillImage = GetComponent<Image>(); |
| | 17 | |
|
| 0 | 18 | | coroutine = StartCoroutine(LoadinAnimation()); |
| 0 | 19 | | } |
| | 20 | |
|
| 0 | 21 | | private void OnDisable() { StopCoroutine(coroutine); } |
| | 22 | |
|
| | 23 | | IEnumerator LoadinAnimation() |
| | 24 | | { |
| 0 | 25 | | fillImage.fillAmount = 0; |
| 0 | 26 | | float currentSpeed = animSpeed * Time.deltaTime; |
| 0 | 27 | | while (true) |
| | 28 | | { |
| 0 | 29 | | fillImage.fillAmount += currentSpeed; |
| | 30 | |
|
| 0 | 31 | | if (fillImage.fillAmount >= 1) |
| 0 | 32 | | currentSpeed = -animSpeed * Time.deltaTime; |
| 0 | 33 | | else if (fillImage.fillAmount <= 0) |
| 0 | 34 | | currentSpeed = animSpeed * Time.deltaTime; |
| | 35 | |
|
| 0 | 36 | | yield return null; |
| | 37 | | } |
| | 38 | | } |
| | 39 | | } |