feat: detect key in background
This commit is contained in:
parent
3e34a7a048
commit
680481afad
13 changed files with 460 additions and 19 deletions
28
Assets/Scripts/ClickTest.cs
Normal file
28
Assets/Scripts/ClickTest.cs
Normal file
|
@ -0,0 +1,28 @@
|
|||
using SatorImaging.AppWindowUtility;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class ClickTest : MonoBehaviour {
|
||||
[SerializeField] private TMP_Text text;
|
||||
private int _presses;
|
||||
private bool _pressed;
|
||||
private const int Key = 0xBF;
|
||||
|
||||
private void OnEnable() {
|
||||
AppWindowUtility.AlwaysOnTop = true;
|
||||
}
|
||||
|
||||
private void Update() {
|
||||
if (_pressed && Win32API.GetAsyncKeyState(Key) == 0) {
|
||||
Debug.Log("unpressed");
|
||||
_pressed = false;
|
||||
return;
|
||||
}
|
||||
if (!_pressed && Win32API.GetAsyncKeyState(Key) != 0) {
|
||||
Debug.Log("pressed");
|
||||
_presses++;
|
||||
text.text = _presses.ToString();
|
||||
_pressed = true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue