/// <summary> /// Disable interactability with this page and tell the page to animate out of the game /// Do not set isOn to false until the page animation is done /// </summary> IEnumerator RunExitSequence() { SetAnimState(false, true); SetInteractability(false); isTurningOff = true; while (!anim.GetCurrentAnimatorStateInfo(0).IsName("Exit")) { yield return(wait); } while (anim.GetCurrentAnimatorStateInfo(0).normalizedTime < 1 || anim.IsInTransition(0)) //is the animation over? { yield return(wait); } OnPageExit(); canvas.alpha = 0; isOn = false; manager.ConfirmPageHasExited(pageType); isTurningOff = false; gameObject.SetActive(false); }