- Home /
Fade Out On Click
Hey Guys, Trying to design a main menu with a fade out on click feature on the text, the problem seems to be that whenever I click it will fade out by 1 frame, and I have to keep clicking to get it to fade out completely, or hold down the mouse.At the moment the click code is highlighted out so it's just flashing. Below is the code i'm using, any help would be greatly appreciated. -Pete
pragma strict
var particle : Component;
var colorStart = Color.blue;
var colorEnd = Color.clear;
var duration = 1.0;
function Update () {
// if (Input.GetKey ("mouse 0"))
// {
var lerp = Mathf.PingPong (Time.time, duration) / duration;
renderer.material.color = Color.Lerp (colorStart, colorEnd, lerp); // } }
/*function OnMouseDown ()
{
Color_Cycle();
//Application.LoadLevel("LevelOne");
}*/
Answer by Stormizin · May 24, 2013 at 12:06 PM
This is the way i do on C#:
public float alphaValue = 1.0f;
public bool check = false;
void Update(){
if(check){
alphaValue -= Mathf.Clamp01(Time.deltatime/0.5)
}
}
void OnGUI(){
GUI.Color = new Color(1,1,1,alphaValue);
if(GUI.Button(new Rect(100,100,100,25), "myButton")){
check = true;
}
}
This will fade out your button, try to make the same way to fade in again.
Your answer
Follow this Question
Related Questions
Select something using mouseclick 2 Answers
tranparent object 1 Answer
Teleporter 2 Answers
Transitions When Pausing? 1 Answer
2D platformer levers and moving platforms question. 0 Answers