Tastaturinteraktion für die grundlegende Verwendung von Unity InputSystem

Holen Sie sich die Tastatur

Keyboard keyboard = Keyboard.current 

Tastaturinteraktion

keyboard[Key.Space].isPressed  按下空格键持续
keyboard[Key.Space].wasPressedThisFrame  按下空格键
keyboard[Key.Space].wasReleasedThisFrame 抬起空格键

Rufen Sie die Zeicheneingabe über die Tastatur ab

    Keyboard keyboard;
    private void Awake()
    {
    
    
        keyboard = Keyboard.current;
        keyboard.onTextInput += onTextInput; 注册事件
    }
    private void onTextInput(char obj) 打印获取的字符
    {
    
    
        Debug.Log("键盘输入" + obj);
    }
    private void OnDestroy()
    {
    
    
        keyboard.onTextInput -= onTextInput; 取消注册
    }

Supongo que te gusta

Origin blog.csdn.net/weixin_43796392/article/details/132724565
Recomendado
Clasificación