InputDevicePartDispatchEventBase.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 {
  8. public abstract class InputDevicePartDispatchEventBase : SCModule {
  9. public InputDevicePartBase inputDevicePartBase;
  10. public InputDevicePartKeyEvent inputDevicePartKeyEvent;
  11. public InputDevicePartDispatchEventBase(InputDevicePartBase inputDevicePartBase) {
  12. this.inputDevicePartBase = inputDevicePartBase;
  13. eventList.Add(inputDevicePartKeyEvent = new InputDevicePartKeyEvent(this));
  14. }
  15. public DispatcherBase dispatcherBase;
  16. public List<InputDevicePartEventBase> eventList = new List<InputDevicePartEventBase>();
  17. public override void OnSCAwake() {
  18. base.OnSCAwake();
  19. AddModule(dispatcherBase);
  20. foreach(var item in eventList) {
  21. AddModule(item);
  22. }
  23. }
  24. public override void OnSCStart() {
  25. base.OnSCStart();
  26. dispatcherBase?.ModuleStart();
  27. foreach(var item in eventList) {
  28. item.ModuleStart();
  29. }
  30. }
  31. public override void OnSCDestroy() {
  32. base.OnSCDestroy();
  33. dispatcherBase = null;
  34. eventList = null;
  35. }
  36. }
  37. }