TrackablePlaneBehaviour.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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 plane behaviour. </summary>
  13. public class TrackablePlaneBehaviour : NRTrackableBehaviour
  14. {
  15. /// <summary> Gets the trackable plane. </summary>
  16. /// <value> The trackable plane. </value>
  17. public NRTrackablePlane TrackablePlane
  18. {
  19. get
  20. {
  21. return (NRTrackablePlane)Trackable;
  22. }
  23. }
  24. /// <summary> Updates this object. </summary>
  25. private void Update()
  26. {
  27. if (TrackablePlane != null && TrackablePlane.GetTrackingState() == TrackingState.Tracking)
  28. {
  29. Pose pos = Trackable.GetCenterPose();
  30. transform.position = pos.position;
  31. transform.rotation = pos.rotation;
  32. transform.localScale = new Vector3(TrackablePlane.ExtentX, 0.001f, TrackablePlane.ExtentZ);
  33. }
  34. }
  35. }
  36. }