arfoundation-samples icon indicating copy to clipboard operation
arfoundation-samples copied to clipboard

Disable Point Cloud particles/visuals

Open dorkbot opened this issue 7 years ago • 4 comments

I want to start the AR Planar experience with the Point Cloud displaying the particles, but I want to turn them off after a few seconds (when the user places an object). In ARFoundation 1 I did this -> pointCloudManager.pointCloud.GetComponent<ARPointCloudParticleVisualizer>().enabled = false;

And that worked. But now ARFoundation has more than one point cloud. I've tried adding a listener an enumerating over the added and updated points. But that doesn't work.

private void PointCloudsChangedHandler(ARPointCloudChangedEventArgs eventArgs)
        {
            for (int i = 0; i < eventArgs.added.Count; i++)
            {
                eventArgs.added[i].GetComponent<ARPointCloudParticleVisualizer>().enabled = false;
            }

            for (int i = 0; i < eventArgs.updated.Count; i++)
            {
                eventArgs.added[i].GetComponent<ARPointCloudParticleVisualizer>().enabled = false;
            }
        }

And tips?

dorkbot avatar May 20 '19 22:05 dorkbot

Try deactivating the point clouds' GameObjects instead. The visualizer enables or disables the particle system based on the tracking state each time it is updated.

If you don't need the point clouds at all anymore (i.e., you aren't also using the data in some other way), the better way to do what you want would be

ARPointCloudManager pointCloudManager = ...

// Stop updating point clouds
pointCloudManager.enabled = false;

// Disable each existing one
foreach (var pointCloud in pointCloudManager.trackables)
{
  pointCloud.gameObject.SetActive(false);
}

tdmowrer avatar May 21 '19 01:05 tdmowrer

thank you. that worked.

dorkbot avatar May 22 '19 00:05 dorkbot

Great! I'll close this issue.

tdmowrer avatar May 22 '19 00:05 tdmowrer

Thank you.

bduunity avatar Oct 30 '21 06:10 bduunity