- Home /
GUI question
Hi all. Need some help. Im working on a game, and I have encountered this problem.. To be more specific, I'm really new to scripting... aand..
I want to have a GUI label text fade in and fade out when the player enters or leaves the trigger area, accordingly . Lets say, when the player approaches a flashlight with a sphere collider in a specific distance to pick it up, I want the GUI to slowly fade in with "Press key E to pick up the flashlight", and continue to display this text while the player is still in the triggered area and when he finally picks the flashlight, then I want the GUI to fade in with "Press key F to toggle the flashlight", wait for the player to press the button, and then fade out once the key is pressed, never to appear again..
The code for picking up the flashlight so far:
var SpawnTo : Transform;
var Flashlight : Transform;
var dist = 3;
private var isHolding = false;
function Update () {
if(Input.GetKeyDown ("e")){
if(Vector3.Distance(transform.position, Flashlight.position) < dist)
{
isHolding = !isHolding;
}
}
if(isHolding == true){
Flashlight.rigidbody.useGravity = false;
Flashlight.parent = SpawnTo;
Flashlight.transform.position = SpawnTo.transform.position; //sets position
Flashlight.transform.rotation = SpawnTo.transform.rotation; //sets rotation
}
else{
}
}
Any help appreciated :)
Answer by proandrius · Apr 27, 2013 at 11:40 PM
Follow this answer http://answers.unity3d.com/questions/272648/fade-in-gui-label.html
Your answer
Follow this Question
Related Questions
turn gui label red on key down (js) 1 Answer
GUI.Label is not showing up! 1 Answer
Help with destroying guiRect? 0 Answers
Text fields where text will scale along with resolution. 1 Answer
How to group variables in the Inspector? 5 Answers