Only Number in textField C#

Hi and happy new year evryone.
I try to make an input control in a TextField but i can not use the system.windows.form under Mono.
Is there a way to only write number and use delete and suppr key in a textField with C#.
thanks

Ok I find a nice way to do it :smile:
with thoses two lines

using System.Text.RegularExpressions;

private string onlyNumbers = "";

void OnGUI()
{
onlyNumbers= GUI.TextField(new Rect(30, 110, 30, 20), onlyNumbers, 3);
onlyNumbers= Regex.Replace(onlyNumbers, "[^0-9]", "");
}

thanx to Fishypants and Timmer :wink:

1 Like

Thanks Babator for sharing your solution.

Very helpful, thanks!!!

You are hero, man! Thanx!