- Home /
Question by
AndreasX12 · Sep 13, 2014 at 04:51 PM ·
functiononcetouchscreenkeyboard
TouchScreenKeyboard done
Hi.
How can I run a function once, when the mobile user is finished using the keyboard?
This is my current code:
public string textInput = ""; //Indtast adresse
private string[] geoData;
private TouchScreenKeyboard keyboard;
public GameObject searchText;
public GameObject searchObj;
void OnMouseUpAsButton() {
TouchScreenKeyboard.hideInput = true;
if(textInput == "No input") {
textInput = "";
}
keyboard = TouchScreenKeyboard.Open(textInput, TouchScreenKeyboardType.ASCIICapable,false,false,false,false);
}
// Update is called once per frame
void Update () {
if(keyboard != null) {
textInput = keyboard.text;
searchText.guiText.text = textInput;
}
if(keyboard != null && keyboard.done == true) {
print("done");
}
}
However, it prints done every frame after I press the 'Enter' button on my mobile keyboard. How can I make this run only once?
Best regards.
Comment
Best Answer
Answer by digibawb · Sep 13, 2014 at 05:47 PM
Just set the keyboard field to null after you have performed the done action.
Your answer
Follow this Question
Related Questions
Run function once, is this method appropriate? 2 Answers
Calling A Function Once 0 Answers
Calling a function only once in Update 3 Answers
How I can call a function once on the "Update" function? 3 Answers