public void Init(float delay, Animation anim, params UnityAction[] actions) { foreach (var action in actions) { onClick.AddListener(() => StartCoroutine(Delayer(delay, anim))); onClick.AddListener(action); } }
private IEnumerator Delayer(float time, Animation anim) { var timer = 0f; interactable = false; var textColor = _text.color; anim.Play(0.2f, 6f, AnimationType.Rotating, Ease.Linear); DOTween.To(() => textColor.a, x => textColor.a = x, 0f, 0.5f).SetDelay(time); while (timer < time) { timer += time; yield return(new WaitForSeconds(time)); } anim.Stop(); DOTween.To(() => textColor.a, x => textColor.a = x, 0f, 0.5f).SetDelay(time); interactable = true; }