• unity 按tab键切换下一个inputfild


    using UnityEngine;  
    using UnityEngine.UI;  
    using UnityEngine.EventSystems;  
      
    public class InputNavigator : MonoBehaviour, ISelectHandler, IDeselectHandler  
    {  
        EventSystem _system;  
        private bool _isSelect = false;  
      
        void Start()  
        {  
            _system = EventSystem.current;  
        }  
      
        void Update()  
        {  
            if (Input.GetKeyDown(KeyCode.Tab) && _isSelect)  
            {  
      
                Selectable next = null;  
                if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))  
                {  
                    next = _system.currentSelectedGameObject.GetComponent<Selectable>().FindSelectableOnUp();  
                }  
                else  
                {  
                    next = _system.currentSelectedGameObject.GetComponent<Selectable>().FindSelectableOnDown();  
                }  
                if (next != null)  
                {  
                    InputField inputfield = next.GetComponent<InputField>();  
                    _system.SetSelectedGameObject(next.gameObject, new BaseEventData(_system));  
                }  
                else  
                {  
                    Debug.LogError("找不到下一个控件");  
                }  
            }  
        }  
      
        public void OnSelect(BaseEventData eventData)  
        {  
            _isSelect = true;  
        }  
      
        public void OnDeselect(BaseEventData eventData)  
        {  
            _isSelect = false;  
        }  
    } 
  • 相关阅读:
    命令别名与历史命令
    Shell的变量功能
    Shell的变量功能
    认识BASH这个Shell
    vim程序编辑器
    其他vim使用注意事项
    vim的额外功能
    六、集合
    五、字典
    四、列表 元组
  • 原文地址:https://www.cnblogs.com/0315cz/p/8306052.html
Copyright © 2020-2023  润新知