31 lines
839 B
C#
31 lines
839 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
public class Switchinginput : MonoBehaviour
|
|
{
|
|
public InputField[] inputFields;//输入框组
|
|
int index = 0;//索引下标
|
|
private EventSystem _eventSystem;
|
|
void Start()
|
|
{
|
|
//设置选中对象
|
|
_eventSystem = EventSystem.current;
|
|
_eventSystem.SetSelectedGameObject(inputFields[index].gameObject, new BaseEventDate(_eventSystem));
|
|
}
|
|
void Update()
|
|
{
|
|
if (Input.GetKeyDown(KeyCode.Tab))
|
|
{
|
|
index++;
|
|
if (index >= inputFields.Length)
|
|
{
|
|
index = 0;
|
|
}
|
|
}
|
|
_eventSystem.SetSelectedGameObject(inputFields[index].gameObject, new BaseEventDate(_eventSystem));
|
|
}
|
|
}
|