InputDeviceHandPart.cs 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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.InputDeviceHand {
  8. public class InputDeviceHandPart : InputDevicePartBase {
  9. public InputDeviceHand inputDeviceHand {
  10. get { return Transition<InputDeviceHand>(inputDeviceBase); }
  11. }
  12. public InputDeviceHandPartUI inputDeviceHandPartUI {
  13. get { return Transition<InputDeviceHandPartUI>(inputDevicePartUIBase); }
  14. }
  15. public HandDetector gGT26DofDetector {
  16. get { return Transition<HandDetector>(detectorBase); }
  17. }
  18. public InputDataHand inputDataHand {get; set;}
  19. public InputDataGetHand inputDataGetHand { get; set; }
  20. public InputDeviceHandPartStatus inputDevicePartStatusHand { get; set; }
  21. public InputDevicePartDispatchEventHand inputDevicePartDispatchEventHand { get; set; }
  22. public override void OnSCAwake()
  23. {
  24. ModuleCreater();
  25. AddModule(inputDataBase);
  26. AddModule(inputDevicePartStatusBase);
  27. AddModule(inputDataGetBase);
  28. AddModule(inputDevicePartUIBase);
  29. AddModule(detectorBase);
  30. //Must after detectorBase ,detectorBase will fill part.scpointerdata,inputDevicePartDispatchEventBase will use it
  31. AddModule(inputDevicePartDispatchEventBase);
  32. }
  33. public override void OnSCStart() {
  34. if (inputDataBase != null)
  35. inputDataBase.ModuleStart();
  36. if (inputDevicePartStatusBase != null)
  37. inputDevicePartStatusBase.ModuleStart();
  38. }
  39. protected override void SubModuleStatusChange() {
  40. if (inputDataBase.isVaild == false) {
  41. if (inputDataGetBase != null && inputDataGetBase.IsModuleStarted)
  42. inputDataGetBase.ModuleStop();
  43. if (inputDevicePartUIBase != null && inputDevicePartUIBase.IsModuleStarted)
  44. inputDevicePartUIBase.ModuleStop();
  45. if (detectorBase != null && detectorBase.IsModuleStarted)
  46. detectorBase.ModuleStop();
  47. if (inputDevicePartDispatchEventBase != null && inputDevicePartDispatchEventBase.IsModuleStarted)
  48. inputDevicePartDispatchEventBase.ModuleStop();
  49. } else {
  50. if (inputDataGetBase != null && !inputDataGetBase.IsModuleStarted)
  51. inputDataGetBase.ModuleStart();
  52. if (inputDevicePartUIBase != null && !inputDevicePartUIBase.IsModuleStarted)
  53. inputDevicePartUIBase.ModuleStart();
  54. if (detectorBase != null && !detectorBase.IsModuleStarted)
  55. detectorBase.ModuleStart();
  56. if (inputDevicePartDispatchEventBase != null && !inputDevicePartDispatchEventBase.IsModuleStarted)
  57. inputDevicePartDispatchEventBase.ModuleStart();
  58. }
  59. }
  60. protected override void ModuleCreater() {
  61. inputDevicePartDispatchEventBase = inputDevicePartDispatchEventHand = new InputDevicePartDispatchEventHand(this);
  62. }
  63. }
  64. }