Такой вопрос - у меня есть форма авторизации построенная с помощью canvas. Все работает, все красиво выглядит, он вдруг обнаружилась одна деталь - невозможность переключиться из одного поля ввода в другое с помощью клавиши Tab. Если с инпутами из стандартного GUI таки проблем нет, то тут вот обнаружилось.
Соответственно вопрос - есть ли решение данной проблемы? В инете поискал, нашел какие-то варианты вроде:
Синтаксис:
Используется csharp
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class InputNavigator : MonoBehaviour
{
EventSystem system;
void Start()
{
system = EventSystem.current;// EventSystemManager.currentSystem;
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Tab))
{
Selectable next = system.currentSelectedGameObject.GetComponent<Selectable>().FindSelectableOnDown();
if (next != null)
{
InputField inputfield = next.GetComponent<InputField>();
if (inputfield != null)
inputfield.OnPointerClick(new PointerEventData(system)); //if it's an input field, also set the text caret
system.SetSelectedGameObject(next.gameObject, new BaseEventData(system));
}
//else Debug.Log("next nagivation element not found");
}
}
}
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class InputNavigator : MonoBehaviour
{
EventSystem system;
void Start()
{
system = EventSystem.current;// EventSystemManager.currentSystem;
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Tab))
{
Selectable next = system.currentSelectedGameObject.GetComponent<Selectable>().FindSelectableOnDown();
if (next != null)
{
InputField inputfield = next.GetComponent<InputField>();
if (inputfield != null)
inputfield.OnPointerClick(new PointerEventData(system)); //if it's an input field, also set the text caret
system.SetSelectedGameObject(next.gameObject, new BaseEventData(system));
}
//else Debug.Log("next nagivation element not found");
}
}
}
Но неужели нет никакого решения проще, без километров кода?..