CustomEventSystem.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using UnityEngine.EventSystems;
  2. using UnityEngine.InputSystem;
  3. using UnityEngine.InputSystem.LowLevel;
  4. namespace Unity.RenderStreaming.Samples
  5. {
  6. using InputSystem = UnityEngine.InputSystem.InputSystem;
  7. class CustomEventSystem : EventSystem
  8. {
  9. #if !INPUTSYSTEM_1_1_OR_NEWER
  10. protected override void Awake()
  11. {
  12. base.Awake();
  13. unsafe
  14. {
  15. InputSystem.onDeviceCommand += InputSystemOnDeviceCommand;
  16. }
  17. }
  18. private static unsafe long? InputSystemOnDeviceCommand(InputDevice device, InputDeviceCommand* command)
  19. {
  20. if (command->type != QueryCanRunInBackground.Type)
  21. {
  22. // return null is skip this evaluation
  23. return null;
  24. }
  25. ((QueryCanRunInBackground*)command)->canRunInBackground = true;
  26. return InputDeviceCommand.GenericSuccess;
  27. }
  28. protected override void OnApplicationFocus(bool hasFocus)
  29. {
  30. //Do not change focus flag on eventsystem
  31. }
  32. #endif
  33. }
  34. }