InputDeviceGCPartEventBattery.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using UnityEngine;
  7. namespace SC.XR.Unity.Module_InputSystem.InputDeviceGC {
  8. public class InputDeviceGCPartEventBattery : InputDeviceGCPartEventBase {
  9. InputDevicePartDispatchEventGC inputDevicePartDispatchEventGC;
  10. public InputDeviceGCPartEventBattery(InputDevicePartDispatchEventGC inputDevicePartDispatchEventGC) : base(inputDevicePartDispatchEventGC) {
  11. this.inputDevicePartDispatchEventGC = inputDevicePartDispatchEventGC;
  12. }
  13. private int perBatteryLevel = 0;
  14. public override void OnSCStart() {
  15. base.OnSCStart();
  16. perBatteryLevel = inputDevicePartDispatchEventGC.inputDeviceGCPart.inputDataGC.BatteryPower;
  17. }
  18. protected override void OnUpdateEvent() {
  19. currentEvent = GCEventType.Null;
  20. if (perBatteryLevel != inputDevicePartDispatchEventGC.inputDeviceGCPart.inputDataGC.BatteryPower) {
  21. perBatteryLevel = inputDevicePartDispatchEventGC.inputDeviceGCPart.inputDataGC.BatteryPower;
  22. currentEvent = GCEventType.BATTERY_POWER_CHANGE;
  23. }
  24. }
  25. }
  26. }