- Home /
Fade in / Out wont work when reloading level
Im currently a student and am working a project. My issue is everything works fine when loading my menu and going into game however when you quit back to the menu it is just black I assume its something to do with my fade in and out script and not sure why it wouldnt be working.
This script is on the start button for the game
private var load : boolean;
var fadeTexture : Texture2D;
var fadeSpeed = 0.2;
var drawDepth = -1000;
private var alphaIn = 1.0;
private var alphaOut = 0.0;
private var fadeDir = -1;
private var fadeOut : boolean;
private var fadeIn : boolean;
function Start(){
fadeIn = true;
fadeOut = false;
load = false;
}
function OnMouseDown(){
if(Input.GetMouseButtonDown(0) && load == false){
fadeOut = true;
load = true;
yield WaitForSeconds(3);
Application.LoadLevel("zombieGame");
}
}
function OnGUI(){
if (fadeOut == true){
alphaOut -= fadeDir * fadeSpeed * Time.deltaTime;
alphaOut = Mathf.Clamp01(alphaOut);
GUI.color.a = alphaOut;
GUI.depth = drawDepth;
GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height), fadeTexture);
}
if (fadeIn == true){
alphaIn += fadeDir * fadeSpeed * Time.deltaTime;
alphaIn = Mathf.Clamp01(alphaIn);
GUI.color.a = alphaIn;
GUI.depth = drawDepth;
GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height), fadeTexture);
}
}
all I have on the quit button in game is the Application.LoadLevel("menu");
any help would be appreciated
Answer by MorphiusX · May 08, 2014 at 04:35 PM
After some trouble shooting I worked out that the Time.timeScale = 0.0 for the pause menu continues over to the main menu. To fix this i just added Time.timeScale = 1.0 when they click the main menu button in game.
Your answer
Follow this Question
Related Questions
Static Variable not working correctly 0 Answers
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Multiple Splash Screens for a game intro? 2 Answers
Fade in with CrossFadeAlpha 1 Answer
fade in fade out audio manager 0 Answers