- Home /
If statement PLZ HELP!!!!
I typed
var stringToEdit : String = "Hello World";
Function OnGUI () {
stringToEdit = GUI.TextField (Rect (10, 10, 200, 20), stringToEdit, 25);
to make a textbox how do i make an if statement to tell if textbox = "Text"
Comment
Best Answer
Answer by Dave-Carlile · Oct 31, 2013 at 08:21 PM
var stringToEdit : String = "Hello World";
Function OnGUI ()
{
stringToEdit = GUI.TextField (Rect (10, 10, 200, 20), stringToEdit, 25);
if (stringToEdit == "Text")
{
// TODO : your stuff here
}
}
Answer by oliver-jones · Oct 31, 2013 at 08:23 PM
You've pretty much answered your own question:
if(textbox == "Text"){
//Do something
}
But, I'm guessing you want to check if there is actually any text in 'textbox', and not the actual word? In that case:
if(textbox != ""){
//Do Something
}
This basically means: if textbox does NOT equal empty
Your answer
