x


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,

more ▼

asked May 09 '11 at 03:50 PM

M Poirot gravatar image

M Poirot
34 1 1 4

You will need to decrease it with time. It appears you are doing instantly instead. 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!

9 days ago Meater6
(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x570
x504
x379
x313
x286

asked: May 09 '11 at 03:50 PM

Seen: 870 times

Last Updated: 9 days ago