Search Unity

ARFoundatiuon - Hide planes work great, but cant hide point cloud

Discussion in 'AR' started by newguy123, Jan 2, 2019.

  1. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,248
    Hi guys

    I'm sticking all the planes in a list, then cycling through them and turning them off "SetActive(false)" then also disabling the ARPlaneManager. This works great.

    There appears to be no similar trick for the PointCloudManager however. I can turn the manager off, but not hide the points already shown.
     
  2. Saicopate

    Saicopate

    Joined:
    Sep 25, 2017
    Posts:
    76
    hint from the manual:
    Each manager subscribes to relevant AR events, such as planeAdded, planeUpdated, and planeRemoved, and creates GameObjects for each detected trackable. The generated GameObjects are parented to a special GameObject under the ARSessionOrigin, accessible via ARSessionOrigin.trackablesParent.
     
  3. tdmowrer

    tdmowrer

    Joined:
    Apr 21, 2017
    Posts:
    605
    The point cloud manager only creates a single GameObject, which you can get with ARPointCloudManager.pointCloud. Have you tried disabling that?
     
  4. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,248
    I'm using this:

    m_ARPointCloudManager = GetComponent<ARPointCloudManager>();
    ...
    ...
    ...
    void Awake()
    {
    m_SessionOrigin = GetComponent<ARSessionOrigin>();
    m_ARPlaneManager = GetComponent<ARPlaneManager>();
    m_ARPointCloudManager = GetComponent<ARPointCloudManager>();
    }


    then in an update, after the prefab is placed I disable the planes and planemanager, and with similar code attempt to hide the pointcloud:


    m_ARPointCloudManager.pointCloud.enabled = false;
    GetComponent<ARPointCloudManager>().enabled = false;

    But when I run the app and place the prefab, the pointcloud is still visible. What am I missing?
     
  5. Saicopate

    Saicopate

    Joined:
    Sep 25, 2017
    Posts:
    76
    instead of
    Code (CSharp):
    1. m_ARPointCloudManager.pointCloud.enabled = false;
    try
    Code (CSharp):
    1. m_ARPointCloudManager.pointCloud.gameObject.SetActive(false);
     
    jipsen and tdmowrer like this.
  6. tdmowrer

    tdmowrer

    Joined:
    Apr 21, 2017
    Posts:
    605
    This is the correct way to do it.

    An ARPointCloud is just a component that holds some data (the points). It does not visualize them. The prefab you are using likely has something like an ARPointCloudParticleVisualizer or ARPointCloudMeshVisualizer on it, which updates either a ParticleSystem of MeshRenderer with the point cloud points. Disabling the GameObject will disable all its components, including the ParticleSystem or MeshRenderer.
     
    jipsen likes this.
  7. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,248
    Thanks its working now