private IEnumerator AddHeartWithAnimCoroutine() { HeartView heart = Instantiate(_heartViewPrefab, transform); hearts.Add(heart); heart.Animator.SetTrigger(AnimatorResources.CreateHeartTriggerId); yield break; }
private IEnumerator RemoveHeartWithAnimCoroutine() { if (hearts.Count > 0) { HeartView heart = hearts[0]; hearts.RemoveAt(0); heart.Animator.SetTrigger(AnimatorResources.DeleteHeartTriggerId); float animLength = heart.Animator.runtimeAnimatorController.animationClips[0].length; yield return(new WaitForSeconds(animLength)); Destroy(heart.gameObject); } }