-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInputNavigator.cs
35 lines (28 loc) · 1.12 KB
/
InputNavigator.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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");
}
}
}