FarPointer.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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.InputDeviceHand {
  9. public class FarPointer : PointerBase {
  10. public HandDetector handDetector {
  11. get {
  12. return detectorBase as HandDetector;
  13. }
  14. }
  15. [HideInInspector]
  16. public float FarDetectDistance = 30f;
  17. public override PointerType PointerType { get => PointerType.Far; }
  18. public Action<bool> TargetDetectModelChange;
  19. protected override void UpdateTransform() {
  20. transform.position = handDetector.inputDeviceHandPart.inputDeviceHandPartUI.modelHand.ActiveHandModel.GetJointTransform(FINGER.forefinger, JOINT.Four).position;
  21. transform.rotation = SvrManager.Instance.leftCamera.transform.rotation;
  22. }
  23. protected override void DoTargetDetect() {
  24. SCInputModule.Instance.ProcessCS(handDetector.inputDevicePartBase.inputDataBase.SCPointEventData, transform, LayerMask, FarDetectDistance);
  25. IsFocusLocked = handDetector.inputDevicePartBase.inputDataBase.SCPointEventData.DownPressGameObject != null;
  26. }
  27. public override void OnSCDisable() {
  28. base.OnSCDisable();
  29. IsFocusLocked = false;
  30. }
  31. }
  32. }