Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

How to save text and display using Touch Screen Keyboard

$
0
0
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); }

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>