- Home /
Fading from my splash screen
Basically I have a scene with a splash screen and I want it to fade in from the unity splash screen and fade out to my game menu. I want the splash screen also to stay for 2 seconds and then fade out. I would love for the script to be javascript but it can be c#. I've seen questions about splash screens before but none of them work for me.
Answer by Foo-Byte · Nov 29, 2015 at 09:56 AM
I would create a full-screen black (or white) image that starts fully opaque. Then slowly fade it to transparent, leave it that way for 2 seconds, then fade it back to being opaque.
This is basically the same technique that is used in the Survival Shooter Unity demo project for the red flash when the player gets hurt.
This is a coroutine I use to fade-to-black that illustrates the principle. fader
is a reference to the full-screen black image.
private IEnumerator FadeToBlackCoroutine() {
Debug.Log("Fading");
float fade = 0.0f;
fader.SetActive(true);
do {
Color c = fadeImage.color;
c.a = Mathf.Lerp(0.0f, 1.0f, fade);
fadeImage.color = c;
fade += fadeSpeed * Time.deltaTime;
yield return null;
} while(fade <= 1.0f);
Debug.Log("Faded");
}
Your answer
Follow this Question
Related Questions
Fade In / Out UI Image 3 Answers
Fade logo before main menu 2 Answers
Multiple Splash Screens for a game intro? 2 Answers
Changing a GUITexture's alpha gives me no effect in game. 0 Answers
Fade in with CrossFadeAlpha 1 Answer