AllMoveEvent.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. m.OnPointerUp(part.inputDataBase.SCPointEventData);
  31. }
  32. else
  33. {
  34. if (obj.transform.parent != null)
  35. checkMoveUp(obj.transform.parent.gameObject, part);
  36. }
  37. }
  38. }
  39. private void downEvent(InputKeyCode keyCode, InputDevicePartBase part)
  40. {
  41. if (part.inputDataBase.SCPointEventData.pointerCurrentRaycast.gameObject != null && part.inputDataBase.SCPointEventData.pointerCurrentRaycast.gameObject.GetComponent<BoxCollider>() == null)
  42. {
  43. checkMoveDown(part.inputDataBase.SCPointEventData.pointerCurrentRaycast.gameObject, part);
  44. }
  45. NowPart = part;
  46. }
  47. public void checkMoveDown(GameObject obj, InputDevicePartBase part)
  48. {
  49. if (obj)
  50. {
  51. ManipulationHandler m = obj.GetComponent<ManipulationHandler>();
  52. if (m != null)
  53. {
  54. m.OnPointerDown(part.inputDataBase.SCPointEventData);
  55. }
  56. else
  57. {
  58. if (obj.transform.parent != null)
  59. checkMoveDown(obj.transform.parent.gameObject, part);
  60. }
  61. }
  62. }
  63. // Update is called once per frame
  64. void Update()
  65. {
  66. if (NowPart!=null&&NowPart.inputDataBase.SCPointEventData.pointerCurrentRaycast.gameObject != null && NowPart.inputDataBase.SCPointEventData.pointerCurrentRaycast.gameObject.GetComponent<BoxCollider>() == null)
  67. {
  68. checkMoveDrag(NowPart.inputDataBase.SCPointEventData.pointerCurrentRaycast.gameObject, NowPart);
  69. }
  70. }
  71. public void checkMoveDrag(GameObject obj, InputDevicePartBase part)
  72. {
  73. if (obj)
  74. {
  75. ManipulationHandler m = obj.GetComponent<ManipulationHandler>();
  76. if (m != null)
  77. {
  78. m.OnDrag(part.inputDataBase.SCPointEventData);
  79. }
  80. else
  81. {
  82. if(obj.transform.parent!=null)
  83. checkMoveDrag(obj.transform.parent.gameObject, part);
  84. }
  85. }
  86. }
  87. }