Here’s how I do it. Limits the amount of text in the input field of the keyboard and the length of the “theName” string to 16 characters. The user can type more than 16 chars and they show in the input field of the keyboard for a sec but any chars that make the text length > 16 disappear right quick. I’d rather have a hard limit so they couldn’t type any more in once the desired length had been hit but I couldn’t figure that out.
private var kb : iPhoneKeyboard;
private var theName : String = "Enter your name";
function Update()
{
if (kb)
{
if (kb.active)
{
if (kb.text.length > 16)
{
kb.text = kb.text.Substring(0, 16);
}
theName = kb.text;
}
if (kb.done) { kb = null; }
}
}
function OnGUI()
{
if (GUI.Button(Rect(8, 8, 128, 32), "Keyboard"))
{
kb = iPhoneKeyboard.Open(theName, iPhoneKeyboardType.Default);
}
GUI.Label(Rect(86, 55, 128, 22), theName);
}