- Home /
Keyboard Cursor Delay Issue
Hello, very new unity user here.. I am creating a text adventure in which the return key submits the input text. However, there is a required slight delay between the return and the text clearing in which the text keyword is processed. If there was no delay, the keyword would be treated as the cleared textfield, a.k.a. as blank. Due to this delay, the return causes the keyboard cursor to move up a line and into the bordering text. This is a slight visual issue that I would appreciate if you could help me solve. Pictures attached in order to help understand the problem.
That little pixel right there is the problem, here is the normal image before return is pressed:
Finally, here is my code. Any fixes?
#pragma strict
var arcadeText : GUIStyle;
var stringToEdit : String = "";
private var showBox1 : boolean = true;
function OnGUI () {
// Make a text field that modifies stringToEdit.
var returnHit = (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return);
stringToEdit = GUI.TextField (Rect (19, 397, 600, 20), stringToEdit, 240, arcadeText);
if(returnHit) {
Animate();
}
if (showBox1 == true)
{GUI.Box(Rect(0,0,Screen.width,Screen.height),"Greetings, Adventurer. You have but one goal: to return to reality.\nYou are in a low-lit stone room with a single unlocked door visible.", arcadeText);}
var exitRoom1 = returnHit && stringToEdit == ("exit" || "leave");
if (exitRoom1) {showBox1 = false;}
}
function Animate () { stringToEdit = stringToEdit; yield WaitForEndOfFrame; stringToEdit= "";}
As far as I can tell, if there was a way to process the information after I hit return but with no delay or if the keyboard cursor didn't move up/didn't look like it did ", than it would be fine. Thanks so much for any help you could provide.
Your answer
Follow this Question
Related Questions
Something wrong with or operator 2 Answers
Android port bug? 1 Answer
Why do i get 4 errors here? (Javascript) 1 Answer
playerID does not exist in current context? 3 Answers
unity bug??? while loop is satisfied, but doesn't quit 2 Answers
