How to make an editable 3 lenght numbers area?

I’m trying to do this using a textArea and converting the int to a string, limiting the lenght of the string to 3, but the text it’s getting uneditable… How can I do this?
I want to do something like this:

And I want to pop up the number keyboard on android when user touch the number area. I saw on the support that it’s automatic but i didn’t see how to open the number keyboard.

Could you post some code?

var mainBarStyle : GUISkin;

var numeroDoHino : int = 451;


function OnGUI () {
	var mainBarHeight = Screen.height/5;
	GUI.BeginGroup (Rect (0,0, Screen.width, mainBarHeight), mainBarStyle.box);
	
	GUI.TextField(Rect(0,0,100,40),numeroDoHino.ToString(),3);
	
	GUI.EndGroup ();
}

That’s all, nothing much…

Ok, your problem is that you’re not setting numeroDoHino to the new value - it always stays the same, so the textfield appears uneditable. To fix it, you’ll have to parse the textfield for an int value and set numeroDoHino to that.

Typed in browser, may not execute:

function OnGUI(){
  var textValue = GUI.TextField(Rect(0,0,100,40),numeroDoHino.ToString(),3)
  if(Int32.TryParse(textValue, numeroDoHino)) Debug.Log("Success!");
}

Thanks man! It worked perfectly! I just needed to switch Int32 to int because I’m using js.
And about the mobile keyboard, it’ll open the number keyboard automatic, or the user will need to navigate trhough the normal keyboard to type number?

At least on iOS(I don’t use Android), the keyboard automatically opens when the user taps the textfield. I’d assume that Unity Android does the same.

Yes, I read this and it’s exaclty the same way of iOS but i want to restrict to show only the number keyboard… Any ideia?

iPhoneKeyboardType.NumberPad //Only numbers from 0 to 9.

It says here that android uses the same api’s in unity except for the 2 shown at the “android” tab on that page :wink: