Gui Text won't turn off
What am I doing wrong here? Why is the Gui text always enabled?
#pragma strict
var target : Transform;
var offset = Vector3(0.0, 0.75, 0.0);
var textObject : GUIText;
function Start(){
textObject.GetComponent(GUIText).enabled = false;
}
function Update() {
var pos = target.position + offset;
transform.position = Camera.main.WorldToViewportPoint(pos);
GetComponent.<GUIText>().enabled = (transform.position.z > 0.0);
}
function OnTriggerEnter2D(other: Collider2D)
{
Debug.Log("Trigger Entered!");
textObject.GetComponent(GUIText).enabled = true;
}
function OnTriggerExit2D(other: Collider2D)
{
textObject.GetComponent(GUIText).enabled = false;
}
Comment
Your answer
Follow this Question
Related Questions
Cannot see Text 1 Answer
TextUI text changes size if resolution changes 1 Answer
GUI Text not showing up :( 7 Answers
How to get tooltips to pop up on certain levels, but not all of them 2 Answers
Making texts look smooth good and not pixel crisp no matter their size with TMP & custom fonts 0 Answers