- Home /
fade a button
Is there a good way to make a button fade out when clicked then when transparent destroy it? I have tried the fade script that seems to be a fav here, but it just gives me the does not recognize fade error even when I attach it to objects
Comment
do you speak of a GUI button or a GUI texture button?
Answer by dentedpixel · Apr 26, 2013 at 11:42 AM
LeanTween has alpha fading support for Unity's GUI Elements. Here is an example of fading a button on click:
var buttonRect3:LTRect = new LTRect(0.0, 0.0, 200, 100 );
function OnGUI(){
if(GUI.Button(buttonRect3.rect, "Alpha")){
LeanTween.alpha( buttonRect3, 0.0, 1.0, ["ease",LeanTweenType.easeOutQuad] );
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613112439im_/https://answers.unity.com/themes/thub/images/avi.jpg)