问题
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?
回答1:
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);
来源:https://stackoverflow.com/questions/54131840/unity-3d-enter-number-in-inputfield-and-get-an-event