在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:Elringus/UnityRawInput开源软件地址:https://github.com/Elringus/UnityRawInput开源编程语言:C# 100.0%开源软件介绍:Download packageFor Unity 2017.4 and later: UnityRawInput.unitypackage. Please be aware that you don't need to clone the whole repository in order to use the extension in your project. Either download package from the link above or extract DescriptionWrapper over Windows Raw Input API to hook for the native input events. Allows to receive input events even when the Unity application is in background (not in focus). Will only work on Windows platform. Only keyboard input is currently supported. UsageInclude package namespace. using UnityRawInput; Initialize the input service to start processing native input messages. RawKeyInput.Start(); Optinally, you can specify whether input messages should be handled when the application is not in focus (disabled by default). var workInBackground = true;
RawKeyInput.Start(workInBackground); Add listeners for the input events. RawKeyInput.OnKeyUp += HandleKeyUp;
RawKeyInput.OnKeyDown += HandleKeyDown;
private void HandleKeyUp (RawKey key) { ... }
private void HandleKeyDown (RawKey key) { ... } You can also check whether specific key is currently pressed. if (RawKeyInput.IsKeyDown(key)) { ... } You can stop the service at any time. RawKeyInput.Stop(); Don't forget to remove listeners when you no longer need them. private void OnDisable ()
{
RawKeyInput.OnKeyUp -= HandleKeyUp;
RawKeyInput.OnKeyDown -= HandleKeyDown;
} |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论