- Home /
glowing gui button
i want to create a GUI.Button.
my need is i want to fade in and out the color of Gui.Button with out fading the text inside the gui.button.
i do not want the gui.button to fade.
i want the color inside the gui button should fade in and out like indicator(like traffic light)
i tried with making alpha content a = 0; this if fadding the button itself.i just want the color inside the gui button to fade and fade out
function OnGUI() { GUI.backgroundColor.a = Mathf.Lerp(1.0, 0.0,Time.time*0.1); if(GUI.Button(new Rect(Screen.width *(4.1/6.55), Screen.height*(0.8/6.55),Screen.width*(.4/6.55),Screen.height * (.2/6.55)),"")) {
}
}
i tried this code this fading gui button text along with gui button color.i want text return in the button should not fade along with the color
Answer by marceloroca · Apr 13, 2011 at 12:00 PM
add a label with the same position and set the alpha channel to 1
function OnGUI() { var rect = new Rect(Screen.width *(4.1/6.55), Screen.height*(0.8/6.55),Screen.width*(.4/6.55),Screen.height * (.2/6.55)); GUI.backgroundColor.a = Mathf.Lerp(1.0, 0.0,Time.time*0.1); if(GUI.Button(rect,"")) { Debug.Log("click"); }
GUI.backgroundColor.a = 1;
GUI.Label(rect,"Button");
}
Answer by TheDemiurge · Apr 13, 2011 at 10:58 AM
GUI.backgroundColor is your answer, I think. for Javascript GUI.backgroundColor.a = ...
and for C# GUI.backgroundColor = new Color(r, g, b, a);
(or store it before, so you're not using new
in OnGUI code)
how to get the effect suppose my button is blue color i want the blue color to fade in and out with out fading the text inside the button. i tried this code GUI.backgroundColor.a = $$anonymous$$athf.Lerp(1.0, 0.0,Time.time*0.1); it is fading the the text along with the gui button color
Not sure what to say. I threw only the first two lines into an OnGUI function and it worked. Then I threw in the bit with the Lerp just to test and... it's keeping the text there while changing the alpha of the button itself. Your button isn't saying anything right now but the color fading should still work..
Try something like GUI.backgroundColor = Color(0, 0, 1, $$anonymous$$athf.Lerp(1, 0, Time.time*0.1));
for the heck of it - see if that makes a difference. Not sure what to say otherwise.
Your answer
Follow this Question
Related Questions
How to make GUI button glow 0 Answers
Button Turns Off and On Object 1 Answer
Button then instanitates gameobject 1 Answer
How to hook up the particle system to jump animation? 1 Answer