Fade Camera

Hey everyone, I’m looking for a simple way to make the main camera in the scene, to fade in from black. So basically, I press play, and the scene starts from a black screen, then 2 seconds after its back to the normal scene.

Here are some links that might actually help someone:

  1. Answer using OnGui
  2. Wiki article
  3. Another answer using OnGui

The method is quite similar on all of them, you want to draw a texture in front of the camera that gradually goes from being transparent to black.

Posted as a separate answer for visibility

push the space bar…

	Texture2D blk;
	public bool fade;
	public float alph;
	void Start(){
		//make a tiny black texture
		blk = new Texture2D (1, 1);
		blk.SetPixel (0, 0, new Color(0,0,0,0));
		blk.Apply ();
	}
	// put it on your screen
	void OnGUI(){
		GUI.DrawTexture (new Rect(0, 0, Screen.width, Screen.height),blk);
	}
	
	void Update () {
		if(Input.GetKeyDown("space")){fade=!fade;}
		
		
		if (!fade) {
			if (alph > 0) {
				alph -= Time.deltaTime * .2f;
				if (alph < 0) {alph = 0f;}
				blk.SetPixel (0, 0, new Color (0, 0, 0, alph));
				blk.Apply ();
			}
		} 
		if (fade) {
			if (alph < 1) {
				alph += Time.deltaTime * .2f;
				if (alph > 1) {alph = 1f;}
				blk.SetPixel (0, 0, new Color (0, 0, 0, alph));
				blk.Apply ();
			}
		}
	}

One way:

Create > UI > Image. Stretch to canvas.

void FadeToBlack ()
{
blackScreen.color = Color.black;
blackScreen.canvasRenderer.SetAlpha (0.0f)
blackScreen.CrossFadeAlpha (1.0f, time, false);
}
    
void FadeFromBlack ()
{
blackScreen.color = Color.black;
blackScreen.canvasRenderer.SetAlpha (1.0f)
blackScreen.CrossFadeAlpha (0.0f, time, false);
}

Please Google next time.

https://www.google.com/search?rlz=1C1GGGE_enUS456US456&gcx=c&sourceid=chrome&ie=UTF-8&q=camera+fade+unity3d