ARAnchor.cs 967 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using UnityEngine;
  2. namespace UnityARInterface
  3. {
  4. public class ARAnchor : ARBase
  5. {
  6. [HideInInspector]
  7. public string anchorID;
  8. private ARInterface m_ARInterface;
  9. private bool started;
  10. private void Awake()
  11. {
  12. m_ARInterface = ARInterface.GetInterface();
  13. if (m_ARInterface == null)
  14. Destroy(this);
  15. }
  16. void Start()
  17. {
  18. UpdateAnchor();
  19. started = true;
  20. }
  21. private void OnEnable()
  22. {
  23. if (started)
  24. UpdateAnchor();
  25. }
  26. private void OnDisable()
  27. {
  28. m_ARInterface.DestroyAnchor(this);
  29. }
  30. private void OnDestroy()
  31. {
  32. m_ARInterface.DestroyAnchor(this);
  33. }
  34. public void UpdateAnchor()
  35. {
  36. m_ARInterface.DestroyAnchor(this);
  37. m_ARInterface.ApplyAnchor(this);
  38. }
  39. }
  40. }