logo screen

Hi everyone. I’m trying to do a logo screen, like in many videogames, where an image of a logo is shown on screen for a few seconds and then fades out into a new scene. Does anybody know the code needed for this, as i have got fade in code, where the screen reveals the logo, but i’m not sure how to get it to move to another scene from there. What i need is a timer so after a few seconds it will fade back out and then load to another scene.

If anybody could help me would be greatly appreciated.

Thank you.

Here:

public float time = 5.0f; // The time in seconds you want the screen to last
void Update()
{
time -= Time.deltaTime;
if(time <= 0.0f)
{
// Change scene here
Application.LoadLevel("LEVEL YOU WANT TO LOAD HERE"); // Load new scene
}
}

I have a Splash Screen code in my scene. It doesn’t fade, though. The object also has a DontDestroyOnLoad script attached. It loads the first scene (called hub) behind the images, so the player can start immediately after the second image disappears.

var logo : Texture;
var title : Texture;
var background : Texture;
private var logoActive : boolean;
private var titleActive : boolean;

function Awake() {
	MainMenu.splashActive = true;
	splash();
	Application.LoadLevel ("hub");
}

function splash() {
	logoActive = true;
	yield WaitForSeconds(2.5);
	titleActive = true;
	logoActive = false;
	yield WaitForSeconds(2.5);
	Destroy(gameObject);
}

function OnGUI() {
	GUI.depth = 3;
	GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height), background);
	if(logoActive)
		GUI.DrawTexture(Rect((Screen.width - logo.width)/2, (Screen.height - logo.height)/2, logo.width, logo.height), logo);
	if(titleActive)
		GUI.DrawTexture(Rect((Screen.width - title.width)/2, (Screen.height - title.height)/2, title.width, title.height), title);
}

(Two images; a logo first and the title of the game second.)

Assuming you have two coroutines for the fade-in and fade-out:

public float fDelay = 5.0f;
public string sNextLevel = "Hub";

IEnumerator Start()
{
    yield return StartCoroutine(FadeIn());

    yield new WaitForSeconds(fDelay);

    yield return StartCoroutine(FadeOut());

    Application.LoadLevel(sNextLevel);
}