loudixvmuniu/Assets/_Scripts/Framework/Utilities/InputFieldController.cs

63 lines
1.9 KiB
C#
Raw Normal View History

2025-01-02 12:15:45 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
/********************************************************************************
*Create By CG
*Function <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Tap<EFBFBD>л<EFBFBD><EFBFBD>ı<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*********************************************************************************/
namespace CG.UTility
{
public class InputFieldController : MonoBehaviour, ISelectHandler, IDeselectHandler
{
private bool isSelect = false;
private EventSystem system;
// Use this for initialization
void Start()
{
system = EventSystem.current;
}
private void GetTabDown()
{
if (Input.GetKeyDown(KeyCode.Tab) && isSelect)
{
//<2F><>һ<EFBFBD><D2BB>Ҫ<EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>
Selectable next = null;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܹ<EFBFBD><DCB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>
Selectable now = system.currentSelectedGameObject.GetComponent<Selectable>();
//<2F>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>һ<EFBFBD><D2BB>
next = now.FindSelectableOnDown();
if (next == null)
{
print(<><C3BB><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>");
}
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ܹ<EFBFBD><DCB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
system.SetSelectedGameObject(next.gameObject);
}
}
// Update is called once per frame
void Update()
{
GetTabDown();
}
/// <summary>
/// ʵ<><CAB5>ISelectHandler<65>ӿ<EFBFBD>
/// </summary>
/// <param name="eventData"></param>
public void OnSelect(BaseEventData eventData)
{
isSelect = true;
}
/// <summary>
/// ʵ<><CAB5>IDeselectHandler<65>ӿ<EFBFBD>
/// </summary>
/// <param name="eventData"></param>
public void OnDeselect(BaseEventData eventData)
{
isSelect = false;
}
}
}