SwitchPlaneDetect.cs 1.6 KB

12345678910111213141516171819202122232425262728293031
  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.Experimental.NRExamples
  11. {
  12. /// <summary> A switch plane detect. </summary>
  13. public class SwitchPlaneDetect : MonoBehaviour
  14. {
  15. /// <summary> Switch plane detect configuration. </summary>
  16. /// <param name="flag"> True to flag.</param>
  17. private void SwitchPlaneDetectConfig(bool flag)
  18. {
  19. var config = NRSessionManager.Instance.NRSessionBehaviour.SessionConfig;
  20. config.PlaneFindingMode = flag ? TrackablePlaneFindingMode.HORIZONTAL : TrackablePlaneFindingMode.DISABLE;
  21. NRSessionManager.Instance.SetConfiguration(config);
  22. }
  23. /// <summary> Enables the plane detect. </summary>
  24. public void EnablePlaneDetect() { SwitchPlaneDetectConfig(true); }
  25. /// <summary> Disables the plane detect. </summary>
  26. public void DisablePlaneDetect() { SwitchPlaneDetectConfig(false); }
  27. }
  28. }