SCPointEventData.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. using UnityEngine.EventSystems;
  8. namespace SC.XR.Unity.Module_InputSystem {
  9. public class SCPointEventData : PointerEventData {
  10. public InputDevicePartBase inputDevicePartBase;
  11. public SCPointEventData(InputDevicePartBase inputDevicePartBase, EventSystem eventSystem) : base(eventSystem) {
  12. this.inputDevicePartBase = inputDevicePartBase;
  13. }
  14. public PointerInputModule.MouseButtonEventData MouseButtonEventData = new PointerInputModule.MouseButtonEventData();
  15. /// <summary>
  16. /// 触摸Press的百分比,当为0-1 1表示Press触发
  17. /// </summary>
  18. public float TouchPressPercent = 0;
  19. public Action<float,float> TouchPressPercentDelegate;
  20. /// <summary>
  21. ///碰撞物体中心相对于HitPointer的局部坐标
  22. /// </summary>
  23. public Vector3 HitPointerRelativeRayCasterCamera = Vector3.zero;
  24. public Vector3 HitPointerDeltaDragObjCenter = Vector3.zero;
  25. /// <summary>
  26. /// Drag实时位置,是物体中心位置而不是Focus,通过hitPointer的位置和SelfCentreRelativehitPointerPosition算出的物体因该在的位置
  27. /// </summary>
  28. public Vector3 dragObjPosition = Vector3.zero;
  29. public Vector3 dragAnchorPosition3D = Vector3.zero;
  30. public Vector3 Position3D = Vector3.zero;
  31. public Vector3 PressPosition3D = Vector3.zero;
  32. public Vector3 pressForward = Vector3.zero;
  33. public Vector3 Forward = Vector3.zero;
  34. public GameObject DownPressGameObject;
  35. public void Clear() {
  36. TouchPressPercent = 0;
  37. TouchPressPercentDelegate = null;
  38. HitPointerRelativeRayCasterCamera = Vector3.zero;
  39. HitPointerDeltaDragObjCenter = Vector3.zero;
  40. dragObjPosition = Vector3.zero;
  41. dragAnchorPosition3D = Vector3.zero;
  42. Position3D = Vector3.zero;
  43. PressPosition3D = Vector3.zero;
  44. pressForward = Vector3.zero;
  45. Forward = Vector3.zero;
  46. HitPointerRelativeRayCasterCamera = Vector3.zero;
  47. DownPressGameObject = null;
  48. }
  49. }
  50. }