- Home /
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.
Answer by Aridez · Sep 05, 2016 at 04:26 PM
Here are some links that might actually help someone:
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
Answer by toddisarockstar · Mar 30, 2017 at 02:14 AM
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 ();
}
}
}
Answer by luislodosm · Apr 01, 2017 at 11:31 AM
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);
}
Answer by Justin Warner · Dec 11, 2011 at 04:14 PM
http://answers.unity3d.com/questions/8540/how-to-fade-inout-a-scene.html
Please Google next time.
https://www.google.com/search?rlz=1C1GGGE_enUS456US456&gcx=c&sourceid=chrome&ie=UTF-8&q=camera+fade+unity3d
I hate when people do that, can an answer be more useless? At least you could google before posting.
Here are some links that might actually help someone:
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.
I am only posting 7 years late on this because this kind of needless reply is still a problem today: In the future, it would help to remember that part of other people's googling experience is finding threads just like this where someone asked the community the question they need help with... that's the point of these forums.
@mattskate96, thanks for asking the question back in 2011. I have had great success with simply fading the transparency of a black image in Unity UI. Controlling lights can be more dynamic as well....