Hello,
Im just new in Unity 3D, I having a problem:
I want to fade in fade out some logo (as a start game usual).
I found out this script very useful:
http://www.unifycommunity.com/wiki/index.php?title=FadeInOut
When i try apply the 2nd image, it just appear at the same time with 1st image
And after load logo, the scene doesnt go to scene 2 as i want.
this is my code:
// FadeInOut
//
//--------------------------------------------------------------------
// Public parameters
//--------------------------------------------------------------------
public var fadeOutTexture : Texture2D;
public var fadeOutTexture2 : Texture2D;
public var fadeSpeed = 0.1;
var drawDepth = -1000;
var drawDepth1 = -1000;
//--------------------------------------------------------------------
// Private variables
//--------------------------------------------------------------------
private var alpha = 1.0;
private var fadeDir = -1;
private var alpha1 = 1.0;
private var fadeDir1 = -1;
//--------------------------------------------------------------------
// Runtime functions
//--------------------------------------------------------------------
//--------------------------------------------------------------------
function OnGUI(){
alpha += fadeDir * fadeSpeed * Time.deltaTime;
alpha = Mathf.Clamp01(alpha);
alpha1 += fadeDir1 * fadeSpeed * Time.deltaTime;
alpha1 = Mathf.Clamp01(alpha1);
GUI.color.a = alpha;
GUI.depth = drawDepth;
GUI.color.a = alpha1;
GUI.depth = drawDepth1;
GUI.DrawTexture(Rect(550, 250, 200, 83), fadeOutTexture);
GUI.DrawTexture(Rect(550, 250, 200, 200), fadeOutTexture2);
}
//--------------------------------------------------------------------
function fadeIn(){
fadeDir = -1;
fadeDir1 = -2;
}
//--------------------------------------------------------------------
function fadeOut(){
fadeDir = 1;
fadeDir1 = -2;
}
function Start(){
alpha=1;
fadeIn();
alpha1=2;
fadeIn();
Application.LoadLevel(2);
}