unity Inputfield 回车或者tab换行

using LitJson;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class HTTPLogin : MonoBehaviour
{
    
    public InputField[] IfArray;//外部 拖拽 赋值
    private EventSystem es;
    
    void Start()
    {
       // Instance = this;
        es = EventSystem.current;
        es.SetSelectedGameObject(IfArray[index].gameObject, new BaseEventData(es));

       
    }
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Tab))
        {
            index++;
            Debug.Log("index="+ index+ " IfArray.Length="+ IfArray.Length);
            if (index >= IfArray.Length)
            {
                index = 0;
            }
            es.SetSelectedGameObject(IfArray[index].gameObject, new BaseEventData(es));
        }
      
    }


   
   
}

猜你喜欢

转载自blog.csdn.net/qq_37524903/article/details/126933107