Fading In/Out Image Button and Starting New Scene Unity 3D Example

Here is a simple example of a button fading an image out and fading in a different image on a button in Unity 3d. I have also included how to go to a new scene/level using the button with either index of the scene or by title of the scene.

#pragma strict

var golfImage : Texture2D; // import your image 

function OnGUI () {

	// Fade an image out
	if(Time.time < 3){ // for the first 3 seconds
	    //Fade out
	    GUI.color.a = 1 - Time.time/3; 
		if (GUI.Button (Rect (Screen.width/2,Screen.height - 200 ,80,80), golfImage)) {
    	    Application.LoadLevel (1); // go to scene indexed at 1 if button is pressed
		}

	}
	else{
	//Fade in a button with text in
	    if(Time.time < 6){
	        //Fade in
		    GUI.color.a = (Time.time -3 )/3;
		    print("Time " + Time.time);
		    print((Time.time -3) /3);
	    }
	    if (GUI.Button (Rect (Screen.width/2,Screen.height - 200 ,80,80), "Start")) {
			Application.LoadLevel ("TEST"); // go to scene 'test' if pressed
		}
	}

    GUI.color.a = 1;	

	// Options
	if (GUI.Button (Rect (30, Screen.height -50,80,20), "Options")) {
		Application.LoadLevel ("Options");
	}

    // Homepage
	if (GUI.Button (Rect (130, Screen.height -50,80,20), "Homepage")) {
		Application.LoadLevel (2);
	}

}

Graveyard Database Logo

Has everything you want to know about grave yards. Plus has many celebrites and world leaders graves. Pssst it is my other site

Google + Profile
Check out Android Photo Mapping, its a app/site I been working on

  • wholesale nfl jerseys
  • wholesale nfl jerseys china
  • wholesale sports jerseys