I have a Reset button to reset the entire scene (using SceneManager.LoadScene(0)) but the plane anchors persist. How do I make sure they are removed? I want it to be exactly as if I restarted the app.
I found the answer in a different place so I’ll paste it here in case anyone wonders
public void ResetScene() {
// config is the ARKitWorldTrackingSessionConfiguration I used when the app started
UnityARSessionNativeInterface.GetARSessionNativeInterface().RunWithConfigAndOptions(config, UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking);
}
For anyone chasing a bug related to this, if you’re reusing the UnityARCameraManager included with Unity ARKit plugin it does not specify the UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors and UnityARSessionRunOption.ARSessionRunOptionResetTracking run options mentioned in the post above.
These are necessary in order to gracefully reload ARKit, i.e. after scene transitions to reload your app. If you’re using UnityARCameraManager I’d suggest rolling your own with the ability to specify these run options.