AllMoveEvent.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using SC.XR.Unity.Module_InputSystem;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. public class AllMoveEvent : MonoBehaviour
  7. {
  8. // Start is called before the first frame update
  9. void Start()
  10. {
  11. DispatcherBase.KeyDownDelegateRegister(downEvent);
  12. DispatcherBase.KeyUpDelegateRegister(upEvent);
  13. }
  14. InputDevicePartBase NowPart;
  15. private void upEvent(InputKeyCode keyCode, InputDevicePartBase part)
  16. {
  17. if (part.inputDataBase.SCPointEventData.pointerCurrentRaycast.gameObject != null && part.inputDataBase.SCPointEventData.pointerCurrentRaycast.gameObject.GetComponent<BoxCollider>() == null)
  18. {
  19. checkMoveUp(part.inputDataBase.SCPointEventData.pointerCurrentRaycast.gameObject, part);
  20. }
  21. NowPart = null;
  22. }
  23. public void checkMoveUp(GameObject obj, InputDevicePartBase part)
  24. {
  25. if (obj)
  26. {
  27. ManipulationHandler m = obj.GetComponent<ManipulationHandler>();
  28. if (m != null)
  29. {
  30. if (!m.isParentDrag)
  31. m.OnPointerUp(part.inputDataBase.SCPointEventData);
  32. }
  33. else
  34. {
  35. if (obj.transform.parent != null)
  36. checkMoveUp(obj.transform.parent.gameObject, part);
  37. }
  38. }
  39. }
  40. private void downEvent(InputKeyCode keyCode, InputDevicePartBase part)
  41. {
  42. if (part.inputDataBase.SCPointEventData.pointerCurrentRaycast.gameObject != null && part.inputDataBase.SCPointEventData.pointerCurrentRaycast.gameObject.GetComponent<BoxCollider>() == null)
  43. {
  44. checkMoveDown(part.inputDataBase.SCPointEventData.pointerCurrentRaycast.gameObject, part);
  45. }
  46. NowPart = part;
  47. }
  48. public void checkMoveDown(GameObject obj, InputDevicePartBase part)
  49. {
  50. if (obj)
  51. {
  52. ManipulationHandler m = obj.GetComponent<ManipulationHandler>();
  53. if (m != null)
  54. {
  55. if (!m.isParentDrag)
  56. m.OnPointerDown(part.inputDataBase.SCPointEventData);
  57. }
  58. else
  59. {
  60. if (obj.transform.parent != null)
  61. checkMoveDown(obj.transform.parent.gameObject, part);
  62. }
  63. }
  64. }
  65. // Update is called once per frame
  66. void Update()
  67. {
  68. if (NowPart != null && NowPart.inputDataBase.SCPointEventData.pointerCurrentRaycast.gameObject != null && NowPart.inputDataBase.SCPointEventData.pointerCurrentRaycast.gameObject.GetComponent<BoxCollider>() == null)
  69. {
  70. checkMoveDrag(NowPart.inputDataBase.SCPointEventData.pointerCurrentRaycast.gameObject, NowPart);
  71. }
  72. }
  73. public void checkMoveDrag(GameObject obj, InputDevicePartBase part)
  74. {
  75. if (obj)
  76. {
  77. ManipulationHandler m = obj.GetComponent<ManipulationHandler>();
  78. if (m != null)
  79. {
  80. if (!m.isParentDrag)
  81. m.OnDrag(part.inputDataBase.SCPointEventData);
  82. }
  83. else
  84. {
  85. if (obj.transform.parent != null)
  86. checkMoveDrag(obj.transform.parent.gameObject, part);
  87. }
  88. }
  89. }
  90. }