private IEnumerator Fade() { destination = NavigationManager.RouteInformation[navigateToLevelName].RouteDescription; float t = 0.0f; while (t < 1.0f) { fading = true; yield return(new WaitForSeconds(0.001f)); t = Mathf.Clamp01(t + Time.deltaTime / fadeOutTime); DrawingUtilities.DrawQuad(fadeMaterial, fadeColor, t); } if (navigateToLevelName != "") { SceneManager.LoadScene(navigateToLevelName); } else { SceneManager.LoadScene(navigateToLevelIndex); } while (t > 0.0f) { fading = true; yield return(new WaitForSeconds(0.001f)); t = Mathf.Clamp01(t - Time.deltaTime / fadeInTime); DrawingUtilities.DrawQuad(fadeMaterial, fadeColor, t); } Fading = false; }
private IEnumerator Fade() { float t = 0.0f; while (t < 1.0f) { yield return(new WaitForEndOfFrame()); t = Mathf.Clamp01(t + Time.deltaTime / fadeOutTime); DrawingUtilities.DrawQuad(fadeMaterial, fadeColor, t); } if (navigateToLevelName != "") { Application.LoadLevel(navigateToLevelName); } else { Application.LoadLevel(navigateToLevelIndex); } while (t > 0.0f) { yield return(new WaitForEndOfFrame()); t = Mathf.Clamp01(t - Time.deltaTime / fadeInTime); DrawingUtilities.DrawQuad(fadeMaterial, fadeColor, t); } fading = false; }
private IEnumerator FadeOut() { //Setup a default blank texture for fading if none is supplied float fadeOutTime = 0.5f, fadeInTime = 0.5f; Color fadeColor = Color.black; //Material fadeMaterial = new Material("Shader \"Plane/No zTest\" {" + //"SubShader { Pass { " + //" Blend SrcAlpha OneMinusSrcAlpha " + //" ZWrite Off Cull Off Fog { Mode Off } " + //" BindChannels {" + //" Bind \"color\", color }" + //"} } }"); float t = 1f; //while (t < 1.0f) //{ // yield return new WaitForEndOfFrame(); // t = Mathf.Clamp01(t + Time.deltaTime / fadeOutTime); // DrawingUtilities.DrawQuad(/*fadeMaterial, */fadeColor, t); //} while (t > 0.0f) { yield return(new WaitForEndOfFrame()); t = Mathf.Clamp01(t - Time.deltaTime / fadeInTime); DrawingUtilities.DrawQuad(/*fadeMaterial,*/ fadeColor, t); } }