Hey I was wondering how I can make GUI text appear then disappear.
you can use gui.color.a
like so…
#pragma strict
public var x : float = 1;
public var maxChange : float = 0.1;
public var alphaColor : float = 1;
function OnGUI(){
gui.color.a = alphaColor ;
}
function Update(){
alphaColor = Mathf.MoveTowards(alphaColor, x, maxChange);
if(//whatever){
x = 1;
}
else if(//whatever2){
x = 0;
}
}
Put this on your GUIText:
function Start(){
guiText.material.color.a = 0;
yield WaitForSeconds(2);
FadeIn();
}
function FadeIn(){
while (guiText.material.color.a < 1){
guiText.material.color.a += 0.1 * Time.deltaTime * 2;
yield;
}
yield WaitForSeconds(2);
FadeOut();
}
function FadeOut(){
while (guiText.material.color.a > 0){
guiText.material.color.a -= 0.1 * Time.deltaTime * 2;
yield;
}
Destroy (gameObject);
}
You could also apply an animation to the text, with alpha values keyframed.