Search Unity

AR-Foundation Proper way to turn off planes after basic placement

Discussion in 'Handheld AR' started by sirerr, Nov 24, 2018.

  1. sirerr

    sirerr

    Joined:
    Sep 25, 2016
    Posts:
    5
    Hi I have probably a simple question but I wondering what the best way to do it.

    I am currently working on a game where you place a object where you raycast to the plane. After the object is placed, I got a reference to the planes that were created. How should I turn them off so they aren't seen? Also if I do like simple renderer and collider component off, does it affect them meaning, do they stay in that state until the session is complete?

    Here's what I have for now.

    upload_2018-11-23_21-1-11.png

    Thanks and sorry if this is simple lol

    - sirerr
     
  2. GreeneMachine

    GreeneMachine

    Joined:
    Jul 3, 2015
    Posts:
    126
  3. sirerr

    sirerr

    Joined:
    Sep 25, 2016
    Posts:
    5
    Awesome, thanks very much!
     
    GreeneMachine likes this.
  4. hawken

    hawken

    Joined:
    Aug 22, 2013
    Posts:
    480
    Thanks for that link!
     
    GreeneMachine likes this.
  5. noclew

    noclew

    Joined:
    Jun 10, 2016
    Posts:
    4
    Does this disable only the visualizations? Or, does it completely stop plane detection of the session?
     
    unnanego likes this.
  6. unnanego

    unnanego

    Joined:
    May 8, 2018
    Posts:
    82
    Same question
     
  7. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    547
    unnanego likes this.
  8. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    547
    It only disables the existing ARPlanes' GameObjects; new planes will continue to be detected. If you want to disable plane detection, disable the ARPlaneManager.
     
    unnanego likes this.
  9. Griffo

    Griffo

    Joined:
    Jul 5, 2011
    Posts:
    664
    You say 'planes will continue to be detected' I'm confused dose the first line of code in this function() not disable enable the ARPlaneManager stopping plane detection ?

    Code (CSharp):
    1. public void TogglePlaneDetection()
    2.     {
    3.         m_ARPlaneManager.enabled = !m_ARPlaneManager.enabled;
    4.  
    5.         string planeDetectionMessage = "";
    6.         if (m_ARPlaneManager.enabled)
    7.         {
    8.             planeDetectionMessage = "Disable Plane Detection and Hide Existing";
    9.             SetAllPlanesActive(true);
    10.         }
    11.         else
    12.         {
    13.             planeDetectionMessage = "Enable Plane Detection and Show Existing";
    14.             SetAllPlanesActive(false);
    15.         }
    16.  
    17.         if (togglePlaneDetectionText != null)
    18.             togglePlaneDetectionText.text = planeDetectionMessage;
    19.     }
     
  10. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    547
    Correct, disabling the ARPlaneManager will disable plane detection. I meant that deactivating the existing ARPlanes will not stop plane detection, i.e., what SetTrackablesActive does.
     
    Griffo likes this.
  11. mistergreen2016

    mistergreen2016

    Joined:
    Dec 4, 2016
    Posts:
    123
    When is it appropriate to turn off plane detection?
     
  12. BuoDev

    BuoDev

    Joined:
    Nov 28, 2018
    Posts:
    45
    When you don't want to detect planes. For example, if you have already detected a plane and placed whatever content you need, you can disable the plane detection - assuming you don't need to place more content.