UIDrag.cs 894 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.EventSystems;
  5. using Valve.VR;
  6. public class UIDrag: MonoBehaviour,IPointerDownHandler,IPointerUpHandler
  7. {
  8. public GameObject RightHand;
  9. Transform parent;
  10. // Update is called once per frame
  11. void Update()
  12. {
  13. }
  14. public void startDrag(){
  15. parent = this.gameObject.transform.parent;
  16. this.gameObject.transform.parent = RightHand.transform;
  17. }
  18. public void stopDrag(){
  19. this.gameObject.transform.parent = parent;
  20. }
  21. public void OnPointerDown(PointerEventData eventData)
  22. {
  23. if(!InteractionManagement.Instance.Robot_Locked){
  24. InteractionManagement.Instance.LockRobot(true);
  25. }
  26. startDrag();
  27. }
  28. public void OnPointerUp(PointerEventData eventData)
  29. {
  30. stopDrag();
  31. }
  32. }