WindowGenSui.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class WindowGenSui : MonoSingleton<WindowGenSui>
  5. {
  6. public float jd = 30;
  7. // Update is called once per frame
  8. void Update()
  9. {
  10. this.transform.position = OpenXRCamera.Instance.head.position;
  11. float f = Mathf.Abs(this.transform.eulerAngles.y - OpenXRCamera.Instance.head.eulerAngles.y) - jd;
  12. if (this.transform.eulerAngles.y - OpenXRCamera.Instance.head.eulerAngles.y >= jd&& this.transform.eulerAngles.y - OpenXRCamera.Instance.head.eulerAngles.y < jd+180)
  13. {
  14. if (Mathf.Abs(this.transform.eulerAngles.y - OpenXRCamera.Instance.head.eulerAngles.y) > 180)
  15. {
  16. transform.RotateAround(Vector3.zero, Vector3.up,f);
  17. }
  18. else
  19. {
  20. transform.RotateAround(Vector3.zero, Vector3.up, -f);
  21. }
  22. }
  23. else if (this.transform.eulerAngles.y - OpenXRCamera.Instance.head.eulerAngles.y < -jd && this.transform.eulerAngles.y - OpenXRCamera.Instance.head.eulerAngles.y > -jd - 180)
  24. {
  25. if (Mathf.Abs(this.transform.eulerAngles.y - OpenXRCamera.Instance.head.eulerAngles.y) > 180)
  26. {
  27. transform.RotateAround(Vector3.zero, Vector3.up, -f);
  28. }
  29. else
  30. {
  31. transform.RotateAround(Vector3.zero, Vector3.up,f);
  32. }
  33. }
  34. else if (360 -(this.transform.eulerAngles.y - OpenXRCamera.Instance.head.eulerAngles.y) >= jd && 360 - (this.transform.eulerAngles.y - OpenXRCamera.Instance.head.eulerAngles.y) < 180)
  35. {
  36. transform.RotateAround(Vector3.zero, Vector3.up, -jd - 360 - (this.transform.eulerAngles.y - OpenXRCamera.Instance.head.eulerAngles.y));
  37. }
  38. else if(360 + (this.transform.eulerAngles.y - OpenXRCamera.Instance.head.eulerAngles.y) >= jd && 360 + (this.transform.eulerAngles.y - OpenXRCamera.Instance.head.eulerAngles.y)<180)
  39. {
  40. transform.RotateAround(Vector3.zero, Vector3.up, jd - (360 + (this.transform.eulerAngles.y - OpenXRCamera.Instance.head.eulerAngles.y)));
  41. }
  42. }
  43. }