Hi all, I am following the Stealth Tutorial and using the Fade In/Out script for my game.
Tutorial is here: http://unity3d.com/learn/tutorials/projects/stealth/screen-fader
The problem I am having is that when the level starts, it fades from black to clear absolutely fine, but when I call the EndScene() function, I see the GUITexture enable, but then it doesn’t change the color, its almost like the Lerp doesn’t ever kick in.
Here is the code I am using:
using UnityEngine;
using System.Collections;
public class SceneFadeInOut : MonoBehaviour
{
public float fadeSpeed = 1.5f;
private bool sceneStarting = true;
void Awake()
{
guiTexture.pixelInset = new Rect(0f, 0f, Screen.width, Screen.height);
}
void Update()
{
if(sceneStarting)
{
StartScene();
}
}
void FadeToClear()
{
guiTexture.color = Color.Lerp(guiTexture.color, Color.clear, fadeSpeed * Time.deltaTime);
}
void FadeToBlack()
{
guiTexture.color = Color.Lerp(guiTexture.color, Color.black, fadeSpeed * Time.deltaTime);
}
void StartScene()
{
FadeToClear();
if(guiTexture.color.a <= 0.05f)
{
guiTexture.color = Color.clear;
guiTexture.enabled = false;
sceneStarting = false;
}
}
public void EndScene(int leveltoLoad)
{
guiTexture.enabled = true;
FadeToBlack();
if(guiTexture.color.a >= 0.95f)
{
Application.LoadLevel(leveltoLoad);
}
}
}
Any ideas as to why this might not work?