GUI fade in Fade out

hey everybody i’m new to unity and know nothing about scripting and i wanted to know if there was someway i could fade in and fade out like if i enter a zone it will say the name and then fade out that would be great thanks.

2 Answers

2

Use color.a. This represents a GUI element’s alpha values.

Therefore, if you use OnTriggerEnter or OnCollisionEnter and you have your ‘name’ as a GUIText, you could assign a script to that GUIText and use say:

guiText.color.a += Time.deltaTime * fadeMultiplier; //Fade multiplier can be used if you want to speed up or slow down the fade

You can base the time at which it fades out on an actual timer or using OnTriggerExit or OnCollisionExit, depending on what you want.

Next time, try to broaden out your question a bit more because its rather ambiguous.

Hope that helps! Klep

Coroutines will help also. => OnTrigger... can be coroutines.

I suggest you take a look <a href="http://unifycommunity.com/wiki/index.php?title=AnimatedText">here</a>. It's a script to animate a text on alpha, pos and scale. It is done with curves, so you have full control over it.

That's actually a pretty cool script @Berenger ... but @sk8rboy6289, if you didn't want to use that script (which I doubt you won't :D), like I said you would use OnTriggerEnter or OnCollisionEnter to trigger an event which will fade the pop-up in and then after a certain time has elapsed (using a variable probably based on Time.time), simply fade it back out again. Simple is that. That's what I said in my original answer. ;)

I guess this page would be helpful for you. This can fade both material as well as GUIText of textures.