hi im making a game for the iphone using javascript.I have a scene where the player enter his name,the iphone keyboard pops up but the problem is that theres is no entry limit.I mean i want the player to be able to write his name in less than 8 characters(letters) or so…right now the player can enter infinite characters on the keyboard.
Does anyone know a way around this?
How can i limit the characters pressed on the keyboard?
private var kb : iPhoneKeyboard;
private var theName : String = “”;
private var Nametext : GUIText;
function Awake()
{
Nametext=gameObject.Find(“name”).guiText;
}
function Start()
{
kb = iPhoneKeyboard.Open(theName,iPhoneKeyboardType.Default);
}
function Update()
{
if (kb)
{
if (kb.active)
{
if (kb.text.length > 10)
{
kb.text = kb.text.Substring(0, 10);
}
theName = kb.text;
}
if (kb.done) { kb = null;
}
}
Nametext.guiText.text=""+theName;
}