44 lines
1.2 KiB
C#
Raw Normal View History

2025-09-06 17:17:39 +04:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class Tabable : MonoBehaviour
{
private void Start()
{
Debug.Log("this script is on: " + gameObject.name);
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Tab))
{
Selectable next = system.currentSelectedGameObject?.GetComponent<Selectable>().FindSelectableOnDown();
if (next == null)
{
return;
}
if (next.gameObject.name == "ToggleRememberUsername_LoginScreen")
{
next = next.FindSelectableOnDown();
}
if (next != null)
{
//Debug.Log("Selected : " + next.gameObject.name);
InputField inputfield = next.GetComponent<InputField>();
if (inputfield != null) inputfield.OnPointerClick(new PointerEventData(system));
system.SetSelectedGameObject(next.gameObject, new BaseEventData(system));
}
}
}
private readonly EventSystem system = EventSystem.current;
}