Roses/Assets/Scripts/ClickTest.cs
Gerard Gascón 14fdd4558e cleanup
2024-04-12 15:42:15 +02:00

29 lines
No EOL
664 B
C#

using SatorImaging.AppWindowUtility;
using TMPro;
using UnityEngine;
public class ClickTest : MonoBehaviour {
[SerializeField] private TMP_Text text;
private int _presses;
private bool _pressed;
//VK_OEM_2 = 0xBF | cedilla
//https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
private const int Key = 0xBF;
private void OnEnable() {
AppWindowUtility.AlwaysOnTop = true;
}
private void Update() {
if (_pressed && Win32API.GetAsyncKeyState(Key) == 0) {
_pressed = false;
return;
}
if (!_pressed && Win32API.GetAsyncKeyState(Key) != 0) {
_presses++;
text.text = _presses.ToString();
_pressed = true;
}
}
}