mirror of
https://github.com/xiaopeng12138/MaiDXR.git
synced 2025-01-19 01:24:13 +01:00
Made it possible to switch hand during hold
maybe not stable but
This commit is contained in:
parent
981e2c38d2
commit
f8a39dd34b
@ -10,14 +10,30 @@ public class ButtonToKey : MonoBehaviour
|
||||
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo);
|
||||
public VirtualKeyCode keyToPress;
|
||||
|
||||
private int _insideColliderCount = 0;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_insideColliderCount == 0)
|
||||
{
|
||||
keybd_event(System.Convert.ToByte(keyToPress), (byte)MapVirtualKey((uint)keyToPress, 0), 2, UIntPtr.Zero);
|
||||
}
|
||||
else
|
||||
{
|
||||
keybd_event(System.Convert.ToByte(keyToPress), (byte)MapVirtualKey((uint)keyToPress, 0), 0, UIntPtr.Zero);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
keybd_event(System.Convert.ToByte(keyToPress), (byte)MapVirtualKey((uint)keyToPress, 0), 0, UIntPtr.Zero);
|
||||
_insideColliderCount += 1;
|
||||
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
keybd_event(System.Convert.ToByte(keyToPress), (byte)MapVirtualKey((uint)keyToPress, 0), 2, UIntPtr.Zero);
|
||||
_insideColliderCount -= 1;
|
||||
_insideColliderCount = Mathf.Max(0, _insideColliderCount);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user