- Home /
How to fade a scene in/out
Hey guys
I was wondering, what is the most efficient and easy way to make a scene changing transitions....?
I was looking at http://answers.unity3d.com/questions/8540/how-to-fade-inout-a-scene.html but couldn't seem to get it to work. So far I have figured out that I need a texture over the screen or something like that, but I'm having a bit of trouble... :/
Thanks
-Grady
Well, if you want both the scenes to be moving during the transition, it can be pretty difficult. Just out of interest, are you using Unity Pro? If so, there is an easy way of faking a snapshot transition.
Duck's answer in the question you linked to is spot on. I'm afraid I don't really see the point of this question since it's already answered.
I'm using the free version of unity unfortunately...
And for Eric5h5, I copied the code into a OnGUI() funtion, but I just got errors in the console.... I don't know what I am doing wrong....
Look at the errors, they're surprisingly helpful. Obviously directly copy-pasting won't work, you have to actually understand the code as well! You need to define a member variable on your script to store the current fade level.
Answer by yeoldesnake 1 · Sep 27, 2011 at 01:28 PM
You could draw a Black GUI Texture that fills the screen , whose Alpha would slowly ascend from zero to 1 , then load the level. Then you should set it that whenever the new level is loaded , a black texture is also drawn , but now it's alpha descends from 1 to 0 , that should make for a nice transition and should cover up the loading time.
Which, coincidentally, is exactly the same answer as the one from the link posted with the question!
so would it be easier to draw the texture from code, or make the gui texture as a game object and then try and change it...?
O$$anonymous$$, I managed to get something to work how I wanted it to... Here is the code I used:
var theTexture : Texture2D;
function OnGUI(){
GUI.color.a = $$anonymous$$athf.Lerp(0.0, 1.0, (Time.time / 2));
GUI.DrawTexture(Rect(0,0,Screen.width, Screen.height), theTexture);
}
That is if you want it to fade out straight away, i have to try and find a better value ins$$anonymous$$d of Time.time /2 ...
Your answer
![](https://koobas.hobune.stream/wayback/20220612225013im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Superimposition fade between two scenes 1 Answer
Cross dissolve between scenes 1 Answer
Fading scene in unity 3 Answers
fade between scenes? 1 Answer
Fading To New Scene Problem? 1 Answer