EndExamPanel.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using DG.Tweening;
  5. using UnityEngine.UI;
  6. using ChivaXR.Op;
  7. using ProcedureBYQ;
  8. using VRTK;
  9. public class EndExamPanel : MonoBehaviour
  10. {
  11. /// <summary>
  12. /// 结束考试按钮
  13. /// </summary>
  14. public ButtonItem endExamBtn;
  15. /// <summary>
  16. /// 继续考试按钮
  17. /// </summary>
  18. public ButtonItem continueExamBtn;
  19. public void OnEnable()
  20. {
  21. this.transform.parent.localScale = Vector3.zero;
  22. SetSelfPositionAndDisableCameraMove();
  23. }
  24. public void SetSelfPositionAndDisableCameraMove()
  25. {
  26. Transform hander = VRTK_DeviceFinder.HeadsetTransform();
  27. transform.parent.position = hander.transform.position + new Vector3(hander.transform.forward.x, 0, hander.transform.forward.z).normalized * 1.5f;
  28. transform.parent.eulerAngles = new Vector3(0, hander.transform.eulerAngles.y, 0);
  29. this.transform.parent.DOScale(new Vector3(0.001f, 0.001f, 0.001f), 0.5f);
  30. PlayMoveWayController cameraController = FindObjectOfType<PlayMoveWayController>();
  31. if (cameraController != null) cameraController.enabled = false;
  32. }
  33. void Start()
  34. {
  35. // 确定按钮
  36. endExamBtn.BtnClickState.AddListener(() =>
  37. {
  38. //GeneralMethod.AddDataToStatisticalTable();
  39. ExamManagerForVR.instance.ExamFinish();
  40. transform.parent.DOScale(Vector3.zero, 0.5f).OnComplete(() => Destroy(this.transform.parent.gameObject));
  41. });
  42. // 取消按钮
  43. continueExamBtn.BtnClickState.AddListener(() =>
  44. {
  45. PlayMoveWayController cameraController = FindObjectOfType<PlayMoveWayController>();
  46. if (cameraController != null) cameraController.enabled = true;
  47. transform.parent.DOScale(Vector3.zero, 0.5f).OnComplete(() => Destroy(this.transform.parent.gameObject));
  48. });
  49. }
  50. }