- Home /
show GUIText script not working properly
i have a script that shows a GUIText and prints something to it, and after 10 seconds, disables it. The script does not work, so please help. Here it is.
using UnityEngine;
using System.Collections;
public class Show_Money : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
//if 'T' is pressed
if( Input.GetButtonDown("Show Money"))
//Show amount of money player has
GetComponent<GUIText>().enabled = true;
GetComponent<GUIText>().text = Time.time.ToString("10.0");
guiText.text = "Money Here";
else if
{
GetComponent<GUIText>().enabled = false;
}
}
}
EDIT: Ok, I got it in a working state. My only problem now is to get a time interval between GetComponent().enabled = true; and GetComponent().enabled = false; a time interval of 10 seconds. I don't wanna use the thread.sleep idea because I don't want to stop the UI interactions. Please help me.
Did you assign the button "T" as "Show $$anonymous$$oney"? Is the script doing anything?
And you need to open and close your if statement
if(something)
{ //Begin statement(s)
//Do somehting
} //End if
Then you have no test case for your else if(), I think just an else would work.
@oc007061 you should mark this question as answered and do a Google/UA search on Coroutine/timers and if that doesn't get you going, post a new question.
Answer by getyour411 · Feb 05, 2014 at 12:18 AM
On line 14 at end of if(condition) add {
then end of line 18 add close }
Your answer
![](https://koobas.hobune.stream/wayback/20220613132552im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Use WII Balance to control GUI 0 Answers
unity3d GUI textfield problem 1 Answer
Making a sped up timer in unity 1 Answer
Listener for GUIText.text change? 0 Answers
Cloud recognition in Vuforia 0 Answers