Hey guys,
A user clicks a button and the iphone keyboard pops up. They are prompted to enter their player's name. I want to be able to save the text they enter in Player Prefs so I can grab their name throughout the game. Seemingly simple but nothing is being saved. After the user taps "return" or "done" on the keyboard there is nothing saved but an empty string in the PlayerPrefs. Here's the code:
private string playerName;
void NamePlayer() {
TouchScreenKeyboard keyboard;
keyboard = TouchScreenKeyboard.Open(playerName, TouchScreenKeyboardType.Default, false, false, false, false, "Enter Name");
if (keyboard.active)
playerName = keyboard.text;
PlayerPrefs.SetString("PlayerName",playerName);
}
↧