TagGoManager.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using Unity.XR.CoreUtils;
  2. using UnityEngine;
  3. namespace Ximmerse.XR.Tag
  4. {
  5. /// <summary>
  6. /// Used to correct the coordinates of the TagGroundPlane component.
  7. /// </summary>
  8. public class TagGoManager : MonoBehaviour
  9. {
  10. private XROrigin xROrigin;
  11. private static TagGoManager instance;
  12. public static TagGoManager Instance
  13. {
  14. get
  15. {
  16. return instance;
  17. }
  18. }
  19. private void Awake()
  20. {
  21. instance = this;
  22. xROrigin = FindObjectOfType<XROrigin>();
  23. if (xROrigin != null)
  24. {
  25. gameObject.transform.position = new Vector3(-xROrigin.transform.position.x, -xROrigin.transform.position.y - xROrigin.CameraYOffset, -xROrigin.transform.position.z);
  26. gameObject.transform.rotation = Quaternion.Inverse(xROrigin.transform.rotation);
  27. }
  28. }
  29. void Update()
  30. {
  31. if (xROrigin != null)
  32. {
  33. gameObject.transform.position = new Vector3(-xROrigin.transform.position.x, -xROrigin.transform.position.y - xROrigin.CameraYOffset, -xROrigin.transform.position.z);
  34. gameObject.transform.rotation = Quaternion.Inverse(xROrigin.transform.rotation);
  35. }
  36. }
  37. }
  38. }