简体   繁体   中英

Unity 3D enter Number in Inputfield and get an event

In my game is a Gamobject. If I interact with it by pressing E the inputfield and the Submit button show up.

How can I enter something into the inputField? I figured out to get the mouse by pressing ESC but that aint a beautiful way to do it.

I have seen ways to save the value of inputFields as Strings. does it work the same way with integers?

Assuming you declared inputfield in your script:

public InputField inputField1;

Try to activate inputfield after showing it:

inputField1.ActivateInputField();

To save the value of inputField as integer you need to convert its value to int:

var value = int.Parse(inputField1.text);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM