- Home /
Shrink and change color of GUI
this question is about fading GUI color and size, using time So I've got a game in which you can get a checkpoint. When you enter the boxcollider a GUItexts renderer will get true and after a few seconds the renderer becomes false again. I wanted to make it stand out a littlebit more so I wanted it to popup big and green and then shrink to fontsize 60, become white and stay there for like a second. This should happen in about 3 or four seconds.
var PopupGUI : GUIText;
function OnTriggerEnter( hit : Collider ){ PopupGUI.guiText.enabled = true; PopupGUI.material.color = Color.green; PopupGUI.material.color = Color.white; PopupGUI.fontSize = 100; PopupGUI.fontSize = 60; }
Thanks anyway,
You will need to decrease it with time. It appears you are doing instantly ins$$anonymous$$d. I suggest subtracting X pixel sizes every frame/second.
This has to be done in a function that updates quickly though (such as Update or LateUpdate), and not in "once" function, such as OnTriggerEnter and OnCollisionEnter.
This should shrink it every frame (depending on which function your putting the code in), but it will eventually shrink to negative values. You will need to put a limit on how much it can shrink.
I hope this helps!
Your answer
Follow this Question
Related Questions
change Mesh.colors over time help? 2 Answers
Change colour of int when reaches specific number 1 Answer
Text size / position / fade in code 2 Answers
Color lerp once? 2 Answers
gui.label color change 1 Answer