IEnumerator fadeInText() { yield return(new WaitForSeconds(.5f)); for (float i = 0.0f; i < 1.1f; i += 0.02f) { text.color = new Color(1, 1, 1, i); yield return(new WaitForSeconds(speed)); } yield return(new WaitForSeconds(1.5f)); fadeScript.StartCoroutine("FadeOut", sceneToLoad); }
void Update() { if (Input.GetButtonDown("Fire2") && isInside && !called) { called = true; playerMovementScript.enabled = false; playerRigidbody2D.constraints = RigidbodyConstraints2D.FreezeAll; fadeScript.StartCoroutine("FadeOut", sceneToLoad); if (useSpawnPos) { PlayerPrefs.SetInt("NextSpawnPos", spawnPos); } if (isEndDoor) { PlayerPrefs.DeleteAll(); } } }