LockTargetHandle.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //==========================================================
  2. //
  3. // Copyright (c) Guangzhou Shixiang Technology Co.,Ltd.
  4. // All rights reserved.
  5. //
  6. //==========================================================
  7. using GxrSdk;
  8. using UnityEngine;
  9. using UnityEngine.EventSystems;
  10. public class LockTargetHandle : MonoBehaviour, IPointerDownHandler, IPointerUpHandler, IPointerClickHandler
  11. {
  12. [SerializeField]
  13. private Transform DraggedTarget;
  14. public void OnPointerDown(PointerEventData eventData)
  15. {
  16. }
  17. public void OnPointerUp(PointerEventData eventData)
  18. {
  19. }
  20. public void OnPointerClick(PointerEventData eventData)
  21. {
  22. GxrInputAccessor.RegisterPointerLockOntoCallback(LockCompleted, UnlockCompleted);
  23. GxrInputAccessor.LockPointerOntoDraggedTarget(DraggedTarget);
  24. }
  25. private void LockCompleted()
  26. {
  27. Debug.Log($"[LockTargetHandle][LockCompleted]");
  28. }
  29. private void UnlockCompleted()
  30. {
  31. Debug.Log($"[LockTargetHandle][UnlockCompleted]");
  32. GxrInputAccessor.UnregisterPointerLockOntoCallback(LockCompleted, UnlockCompleted);
  33. }
  34. }