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

ARSession - How to reset it

Discussion in 'AR' started by Leos-Clockworks, May 18, 2020.

  1. Leos-Clockworks

    Leos-Clockworks

    Joined:
    Oct 27, 2017
    Posts:
    18
  2. KyryloKuzyk

    KyryloKuzyk

    Joined:
    Nov 4, 2013
    Posts:
    1,128
    You're probably trying to call it like this ARSession.Reset(). But Reset is an instance method so you need a reference to an instance of ARSession.
    The easiest way to get a reference is to pass it via Inspector. Here is a quick example:
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.XR.ARFoundation;
    3.  
    4.  
    5. public class ARSessionResetExample: MonoBehaviour {
    6.     [SerializeField] ARSession arSession; // assign this field via Inspector
    7.  
    8.  
    9.     void Update() {
    10.         bool needReset = false; // replace with your own code
    11.         if (needReset) {
    12.             arSession.Reset();
    13.         }
    14.     }
    15. }
    16.