12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using UnityEngine;
- using DG.Tweening;
- public class FlashEffect : MonoBehaviour
- {
- private static FlashEffect instance;
- private static Tween showTween;
- public CanvasGroup fill;
- private void Awake()
- {
- instance = this;
- }
- private void OnDestroy()
- {
- instance = null;
- }
- private void Start()
- {
- fill.alpha = 0.0f;
- fill.gameObject.SetActive(false);
- }
- public static void Flash()
- {
- if (showTween != null) showTween.Kill();
- // was causing a problem with getting started game tutorial
- // mock for it
- if (!instance)
- return;
- instance.fill.gameObject.SetActive(true);
- instance.fill.alpha = 1.0f;
- showTween = instance.fill.DOFade(0.0f, 0.7f)
- .SetEase(Ease.OutQuart)
- .OnComplete(OnFlashComplete);
- }
- private static void OnFlashComplete()
- {
- showTween = null;
- instance.fill.gameObject.SetActive(false);
- }
- }
|