TrackableImageBehaviour.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /****************************************************************************
  2. * Copyright 2019 Nreal Techonology Limited. All rights reserved.
  3. *
  4. * This file is part of NRSDK.
  5. *
  6. * https://www.nreal.ai/
  7. *
  8. *****************************************************************************/
  9. using UnityEngine;
  10. namespace NRKernal.NRExamples
  11. {
  12. /// <summary> A trackable image behaviour. </summary>
  13. public class TrackableImageBehaviour : MonoBehaviour
  14. {
  15. /// <summary> The detected marker. </summary>
  16. private NRTrackableImage m_DetectedMarker;
  17. /// <summary> Initializes this object. </summary>
  18. /// <param name="marker"> The marker.</param>
  19. public void Initialize(NRTrackableImage marker)
  20. {
  21. m_DetectedMarker = marker;
  22. }
  23. /// <summary> Updates this object. </summary>
  24. private void Update()
  25. {
  26. if (m_DetectedMarker != null && m_DetectedMarker.GetTrackingState() == TrackingState.Tracking)
  27. {
  28. Vector2 size = m_DetectedMarker.Size;
  29. transform.localScale = new Vector3(size.x, transform.localScale.y, size.y);
  30. }
  31. }
  32. }
  33. }