- Home /
Making a Input Field only accepting numbers
Hi
I am making a multiplayer menu for my game and I want the players to be able to set a port for their servers or when joining one. I am using the new 4.6 beta UI and I can't figure out one thing. How do I make so the text field only accepts numbers? I know how to do it with the old GUI but not with the new one. Do someone know how?
Thanks
Comment
Answer by Suraksha226 · Jul 18, 2019 at 10:16 AM
To do this programatically,
InputField iField = gameobject.GetComponent<InputField>();
iField.characterValidation = InputField.CharacterValidation.Integer;
Your answer
![](https://koobas.hobune.stream/wayback/20220613163417im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Scrolling Input Text Field Using UI 1 Answer
4.6 Textfield clear for another entry 0 Answers
TextField text component not updating 2 Answers
Multiple Buttons To Use One Text Input Field 1 Answer
How to modify EditText appearance on Android and iOS? 0 Answers