How can I fade In/Out

So I have a script here. I want to know how I can fade out to and time it so that there is a specific time frame between fade in to fade out.
Please…anyone help.
`

//Author: ----------------------------Electric Fountain----------------------------------

//var tex is the texture for the fade
//var aTexture is the texture I am using for the Logo

var tex: Texture;
var aTexture : Texture;
var _timeOfFade:float=0;
var delta:float;
var postion: Rect;
private var _color:Color=Color(1.0f,1.0f,1.0f,1.0f);

function Update () {
delta=(1/_timeOfFade)*Time.deltaTime;
}
function OnGUI() {
if(_color.a>0){
_color.a-=delta;
GUI.color=_color;
GUI.DrawTexture(postion, tex, ScaleMode.ScaleToFit, true, 10.0f);
if(!aTexture){
Debug.LogError(“Assign a Texture in the inspector.”);
return;
}
GUI.DrawTexture(Rect(143,-200,1000,1000), aTexture);
}
}`

Please hit 'edit', select your code, and hit the 101/010 button to format that code

–

Just use Eric's package http://answers.unity3d.com/questions/314145/create-white-flash-like-an-edit-on-whole-view.html http://wiki.unity3d.com/index.php?title=Fade http://answers.unity3d.com/questions/19962/fade-in-from-black.html everyone uses it !

–

Dave, let me try ... heh :) #Please hit 'edit', select your code, and hit the 101/010 button to format that code

–

1 Answer

1

Hey, man! Welcome to UnityAnswers!
Please follow the comment and format your text to readable code.

I would first look into iTween. It’s a great package that really expands your capabilities in the game engine and is pretty easy to use.

http://itween.pixelplacement.com/index.php

I would make use of the FadeTo function.

If that’s not up your alley, you can always Lerp the alpha!

If you’re trying to change the alpha in UnityGUI, you’re out of luck. You can only change the alpha of the entire GUI by using GUI.color.a in combination with one of the aforementioned methods.

Hope this helps! - YA