Get text from Input field in Unity3D with C#

前端 未结 3 1944
情书的邮戳
情书的邮戳 2020-12-10 02:16

I\'m trying to get a text inside an inputField in Unity3D with C#.

I\'ve placed an inputField in my editor, renamed and tagged in:

3条回答
  •  既然无缘
    2020-12-10 02:55

    using UnityEngine.UI;
    public InputField betInput;
    void Start () {
        betInput.onEndEdit.AddListener(delegate { inputBetValue(betInput); });
    }
    public void inputBetValue(InputField userInput)
    {
        betValue = int.Parse(userInput.text);
        Debug.Log(userInput.text);
    }
    

    https://i.stack.imgur.com/CeF1a.png //This is unity Picture where you select method. Also worth checking out https://unity3d.com/learn/tutorials/topics/scripting/text-input

提交回复
热议问题