- Home /
Shift from one scene to another (based on time)
Hi,
I am making a project right now and I am having some trouble. The game has an intro scene, where just the name of the game is shown (no buttons). I want that scene to go onto the menu that I have made, based on time.
Example: 1. Intro scene loads 2. Wait for 5 seconds 3. Menu appears
Could someone please guide me on what to do?
Thanks a lot.
               Comment
              
 
               
              Answer by GluedBrain · Apr 15, 2013 at 07:57 PM
Create a new scene, create an empty GAMEOBJECT, attach the following script to it
 var MaskTexture : Texture2D;
 static var depth : int;
 var fadeTime = 5.0;
 private var alpha = 0.0;
 enum Fade {In, Out}
 function OnGUI()
 {
     GUI.color = Color(1,1,1,alpha);
     GUI.DrawTexture(Rect((Screen.width / 2 - 685), -15.0, 1370.0, 768.0), 
     MaskTexture, ScaleMode.StretchToFill, true, 0);
     GUI.depth = 1;
 }
 // Fade in the GUITexture, wait a couple of seconds, then fade it out
 
 function Start () {
    yield FadeOnGUIAlpha(fadeTime, Fade.In);
    yield WaitForSeconds(2.0);
    yield FadeOnGUIAlpha(fadeTime, Fade.Out);
    Application.LoadLevel (Application.loadedLevel+1);
    }
 
 function FadeOnGUIAlpha (timer : float, fadeType : Fade) {
    var start = fadeType == Fade.In? 0.0 : 1.0;
    var end = fadeType == Fade.In? 1.0 : 0.0;
    var i = 0.0;
    var step = 1.0/timer;
    while (i < 1.0) {
       i += step * Time.deltaTime;
       alpha = Mathf.Lerp(start, end, i)*.5;
       yield;
    }
  alpha = end;
 }
Your answer
 
 
             Follow this Question
Related Questions
Problem when loading a scene for the second time. 4 Answers
Main Menu with different scenes appearing on background ?! 1 Answer
Load/Save script 0 Answers
Timer to Switch Scene, not working, New to Coding 2 Answers
How to load (restart) last scene 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                