Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Reset ARKit App

Discussion in 'AR' started by Dadi897, Apr 3, 2018.

  1. Dadi897

    Dadi897

    Joined:
    Mar 5, 2018
    Posts:
    8
    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.
     
  2. Dadi897

    Dadi897

    Joined:
    Mar 5, 2018
    Posts:
    8
    I found the answer in a different place so I'll paste it here in case anyone wonders
    Code (CSharp):
    1. public void ResetScene() {
    2.    // config is the ARKitWorldTrackingSessionConfiguration I used when the app started
    3.    UnityARSessionNativeInterface.GetARSessionNativeInterface().RunWithConfigAndOptions(config, UnityARSessionRunOption.ARSessionRunOptionRemoveExistingAnchors | UnityARSessionRunOption.ARSessionRunOptionResetTracking);
    4. }
     
  3. hiachrism

    hiachrism

    Joined:
    Aug 16, 2019
    Posts:
    4
    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.