- Home /
Not showing the message in the text field.
Hi! I was having trouble with this code.
var toggleGUI : boolean; var textFieldString = "text field"; function OnMouseDown () { toggleGUI = true; } function OnGUI () { if (toggleGUI == true){ GUI.Button(Rect (20,40,150,20), "Text Information"); GUI.Button(Rect (20,80,80,20), "Video"); GUI.Button(Rect (20,120,80,20), "Images"); if(Input.GetTouch==GUI.RepeatButton(Rect (20,40,150,20), "Text Information")){ textFieldString = GUI.TextField (Rect (20, 160, 80, 20), textFieldString); } } }
I was able to show three buttons once the user taps the designated collider. The trouble comes when the "Text Information" button is pressed, the message string "text field" does not appear. What am I doing wrong? Thanks in advance!
--EDIT: I realized I used RepeatButton when it should have been just Button. My wrong.
Answer by VictorPinto90 · Sep 23, 2014 at 05:33 PM
Try this code and read about the Input.GetTouch method http://docs.unity3d.com/ScriptReference/Input.GetTouch.html
function OnGUI (){
if (toggleGUI){
if(GUI.RepeatButton(Rect (20,40,150,20), "Text Information")){
textFieldString = GUI.TextField (Rect (20, 160, 80, 20), textFieldString);
}
GUI.RepeatButton(Rect (20,80,80,20), "Video");
GUI.RepeatButton(Rect (20,120,80,20), "Images");
}
}