- Home /
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.
Answer by Kleptomaniac · Mar 12, 2012 at 02:08 AM
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.
also what i want is that when you go into a new zone the name of it will pop up and then fade away like in everquest
I suggest you take a look here. 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. ;)
Your answer
Follow this Question
Related Questions
Fading an image drawn with GUI.DrawTexture 1 Answer
making a fadeout with the new GUI in 4.6? 3 Answers
Fade in from black 4 Answers
Is there anyway to fade in/out a GUI image without using an addon/asset? 2 Answers
How to make 3D Text fade in and out? 3 Answers