FollowOrigin.cs 923 B

12345678910111213141516171819202122232425262728293031
  1. // /******************************************************************************
  2. // * File: FollowOrigin.cs
  3. // * Copyright (c) 2023 Qualcomm Technologies, Inc. and/or its subsidiaries. All rights reserved.
  4. // *
  5. // *
  6. // ******************************************************************************/
  7. using QCHT.Interactions.Core;
  8. using UnityEngine;
  9. namespace QCHT.Samples.Drawing
  10. {
  11. public class FollowOrigin : MonoBehaviour
  12. {
  13. private Transform _origin;
  14. private void Awake() {
  15. _origin = XROriginUtility.GetOriginTransform();
  16. if (!_origin)
  17. DestroyImmediate(this);
  18. }
  19. private void Update() {
  20. if (!_origin) return;
  21. var t = transform;
  22. var originTransform = _origin.transform;
  23. t.position = originTransform.position;
  24. t.rotation = originTransform.rotation;
  25. }
  26. }
  27. }