Unity中获取键盘响应,读卡器可以使用
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class InputScript : MonoBehaviour {
KeyCode currentKey;
void OnGUI()
{
if (Input.anyKeyDown)
{
Event e = Event.current;
if (e.isKey)
{
currentKey = e.keyCode;
print("捕捉到读卡器扫描: " + currentKey.ToString());
}
}
}
}