Unity3D的InputField输入框控件按下Tab键光标自动切换
发布日期:2021-05-10 09:22:24 浏览次数:10 分类:精选文章

本文共 4056 字,大约阅读时间需要 13 分钟。

������������������������������Tab���������������������

������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

���������������������������������

������������������������������������������������������������������������������������������������������������������������������UI������������������������������������������������

  • ��������������������������������������������� scenes ���������
  • ������ SerializedObjectraise ���������������������������������������������������
  • ������������ UIEventListener ��������� Tab ���������������������
  • ��� Tab ������������������������������������ property ���������������������������������������������������
  • ������ EventSystem.current ���������������������������������������������������������������������������������
  • ������ coroutine ������������������������������������������������������������
  • ������������Tab���������������

    ������������Tab���������������������������������������������������:

    fromUnityEngine import *fromUnityEngine.UI import *fromUnityEngine.Events import *fromUnityEngine.EventSystems import *class ChangeCursor : MonoBehaviour {    public Direction direction = Direction.vertical    public enum Direction {        vertical = 0,        horizontal = 1    }    public bool isSelect = false    public override void OnSelect(BaseEventData eventData):        print("���������������������" + eventData.baseEventData.GetComponentName())        isSelect = true    public override void OnDeselect(BaseEventData eventData):        print("���������������������������" + eventData.baseEventData.GetComponentName())        isSelect = false    public void Update:        if Input.GetKeyDown(KeyCode.Tab) && isSelect:            int mark = Input.GetKey(KeyCode.LeftShift) ? -1 : 1            if direction == Direction.horizontal:                mark = -mark  # ������������������������            var current = EventSystem.current.currentSelectedGameObject            current = current.FindSelectablenew("Horizontal")            if current != null:                var inputField = current.GetComponent("InputField")                if inputField != null:                    StartCoroutine(WaitInputField(current))    public static class Utils { ... }    public static Selectable FindLoopSelectable(Selectable current, Vector3 dir):        Selectable first = current.FindSelectable(dir)        if first != null:            current = first            return FindLoopSelectable(first, dir)        return current}class InputField : MonoBehaviour {    public InputField previousField    public void NextField () :        # ������������������������������������������������������        if previousField:            previousField.previousField = null            StartCoroutine( previousField.GetNextField() )}classsel_entry:    public static Selectable FindSelectable (Selectable dir):        while (current as Selectable).FindSelectable(dir) as

    ������������������������������

    ���������������������������������������������������������������������������������������

  • ������������������ inputField ��������� GameObject���
  • ������ Script ���������
  • ������ cursorScript ���������������������
  • ���������������������������������������������������������������������
  • ���������������������������������������������:

  • ������������������������ property ������������������������������������������������
  • ������ Layout ������aurus���������������������������������������������������������
  • ���������������������������������������������������������������������������������
  • ������������������

    ���������������������������������������������������������������������������������������������������

  • ������������������������������
  • ������ Tab ������������������������������
  • ������������������������������������������������
  • ������������������������������������������������������
  • ���������������������������������������������������������������������������������������������������������������������������������������������������������������������

    上一篇:Unity3D获取系统时间并且实时显示
    下一篇:Unity3D实现通用的Image动态切换显示图标

    发表评论

    最新留言

    能坚持,总会有不一样的收获!
    [***.219.124.196]2025年04月10日 14时45分27秒