- Home /
 
Application LoadLevel on Input.KeydownEnter TextField
Am I coding it correctly? It actually doesn't work. I mean when I enter nothing happens but when the character collide to the collider the gui appears. I want to create a portal that has a question attached to it, and when the user input the correct answer and press enter he will go to another scene.
 var showGUI : boolean = false ;
 var ans : String = "Type your answer here.";
 var correct : String = "tombs";
  
 
     function OnTriggerEnter(){
 
         showGUI = true ;
         
     }
  
     function OnTriggerExit(){
 
         showGUI = false ;
         
     }
  
     function OnGUI(){
         if(showGUI){
             GUILayout.Label("It was created and practiced using during Renaissance period?");
             ans = GUI.TextField (Rect (20, 20, 200, 20), ans, 25);
             if(Input.GetKeyDown(KeyCode.Return)){
                 if(ans == correct){
                     Application.LoadLevel("Kingdom");
                 }
             }
         }
      }
 
              
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
LoadLevel Health Question. 1 Answer
How to make my OnTriggerEnter() and Exit work 1 Answer
Can't click gameobject when over another trigger? 1 Answer
How to make a simple inventory?!? Beginner coder JS 1 Answer
GUI text Stays in place 1 Answer