Search code examples
unity-game-engineaugmented-realityarcore

Is there a way to reset ARCore detected surfaces without destroying and remaking the session script?


I'm making an application which uses optional ARCore. This means that I enable and disable the ARCore device on runtime. I noticed that the detected surfaces will still exist even though you disabled and re-enabled the ARCore device.

Is there a way to reset detected surfaces data? I want the users to start fresh every time they open up the AR content.

I have found answers to this in other threads, but all of them involve forcefully destroying the ARCoreSession script from the ARCore device and then re-adding the script back onto it. This seems.. stupid and inefficiënt.


Solution

  • To delete just Detected Planes in your scene (without destroying and recreating an ArSession) is not a good practice using ARCore. An alternative to this is deleting all ArAnchors what are designed to hold Renderables. Although the most robust approach is to destroy a current ArSession and create a new one again.

    Look at this GitHub issue #253 for further details: Clear Planes and Anchors.

    and...

    Look at StackOverflow post How to remove all planes in ARCore to find out more.