- Home /
Focus on text field on load (iPhone)
Hello! Can anybody help me with such a problem? I want to set focus on text field while level is loading and display iPhone keyboard. I thought that this approach will work, but it's not or I did something wrong:
private Rect userNameTextRect; private string userName = "";
...
void OnGUI() { GUI.SetNextControlName ("UserName"); userName = GUI.TextField(userNameTextRect, userName, 10); GUI.FocusControl("UserName"); }
This code works only on desktop for me, but on iPhone TextField is not focused. Can anyone give me some suggestion how may I solve this problem?
Answer by Michael Potter · Feb 07, 2011 at 02:13 AM
Found some approach (not the best, but appropriate in my situation):
private iPhoneKeyboard keyboard; private string userName = "";
void Start () { keyboard = iPhoneKeyboard.Open(userName); }
void OnGUI () { userName = keyboard.text; GUI.Label(userNameTextRect, userName); }
Your answer
Follow this Question
Related Questions
How to focus on TextField2 when TextField1 is compeleted 1 Answer
Changing the keyboard type used on a GUI.TextField 0 Answers
Mobile device textfield keyboard keyset - default to numbers 0 Answers
Can't Input when focus a text field 2 Answers
Using GUI.FocusControl on TextField selects all text 4 Answers