- Home /
 
 
               Question by 
               Dann858 · Feb 14, 2013 at 11:45 PM · 
                c#if-statement  
              
 
              Checking a GUI.Textfield (C#)
I want to check if the player entered the right word in a
  GUI.Textfield(new Rect(x, x, x, x), x, x);
 
               I've tried:
 if(CorrectAnswer1 == "paspoort"){
    GUI.Toggle(new Rect(x, x, x, x,), x, x);
 }
 
               However, this doesn't seem to work. And although I don't get any errors. It won't show me the checked toggle button I want.
I'd be really great if someone could help me. The script has to do with Dutch word checking. Therefor one might not understand the word "paspoort".
               Comment
              
 
               
              Answer by $$anonymous$$ · Feb 15, 2013 at 12:55 AM
save what GUI.textfield returns and check it to see if its correct:
 void OnGUI()
 {
     String userInput = GUI.Textfield(new Rect(x, x, x, x), x, x);
     if(userInput == "paspoort")
     {
            GUI.Toggle(new Rect(x, x, x, x,), x, x);
     }
 }
 
 
              And what if I want someone to fill in multiple words that one has to fill in? After filling all words in one could click a 'Control' button. And once pressed this button calls up a function where the input is checked.
Your answer