C# Unity - How can I clear an InputField

久未见 提交于 2019-12-02 04:19:48

This problem does not exist in the current version of Unity I am running. My advice to you is to update to 5.4.. If you don't want to, then you can select the InputField with code then clear it.

public InputField inputfieldname;
inputfieldname.Select();
inputfieldname.text = "";

You can make this into an extension method.

public static class Extension
{
    public static void clear(this InputField inputfield)
    {
        inputfield.Select();
        inputfield.text = "";
    }
}

Now you can use it like below:

public InputField inputfieldname;
inputfieldname.clear();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!