美文网首页
2018-04-27 UGUI InputField获取输入焦

2018-04-27 UGUI InputField获取输入焦

作者: Nmao | 来源:发表于2018-04-27 15:29 被阅读0次

    UGUI中的InputField控件如何自动获取输入焦点:

    方法1:InputField.ActivateInputField

    usingUnityEngine;

    usingSystem.Collections;usingUnityEngine.UI;

    publicclassExample : MonoBehaviour 

    {

    publicInputField mainInputField;

    // Activate the main input field when the scene starts.

    void Start ()    {        mainInputField.ActivateInputField();  

      }}

    方法2 EventSystem.SetSelectedGameObject

    usingUnityEngine;

    usingSystem.Collections;

    usingUnityEngine.UI;

    publicclassExample : MonoBehaviour

     {

    public  InputField   mainInputField;// Activate the main input field when the scene starts.

    void    Start ()    {        EventSystem.current.SetSelectedGameObject(mainInputField.gameObject);    }}

    相关文章

      网友评论

          本文标题:2018-04-27 UGUI InputField获取输入焦

          本文链接:https://www.haomeiwen.com/subject/drablftx.html