0
\$\begingroup\$

Is there a way to disable and re-enable tracking for images in ARKit? From the older versions, this was the solution. But the newer versions have removed the UnityARSessionNativeInterface script.

void Start ()
{
    m_session = UnityARSessionNativeInterface.GetARSessionNativeInterface();
}

void AddImageAnchor(ARImageAnchor arImageAnchor)
{
    //at the bottom of this function
    StartCoroutine(RemoveAnchorCoroutine(arImageAnchor));
}

IEnumerator RemoveAnchorCoroutine(ARImageAnchor anchor)
{
    yield return new WaitForSeconds(3.0f);
    //doesn't have to be in a coroutine, but for my uses it is
    m_session.RemoveUserAnchor(anchor.identifier);
}
\$\endgroup\$
0
\$\begingroup\$

The current ARKit API doesn't have a method to disable or enable it in Unity, during run-time at this point. With than being said, Unity has its own function to enable and disable VR, AR or XR plugins. If ARKit is built correctly, this method should work. So, you might be able to disable/enable ARKit by setting XRSettings.enabled to false and enable it by setting it to true. It's also a good idea to call XRSettings.LoadDeviceByName with an empty string, wait for frame, before setting XRSettings.enabled to false to disable it:

IEnumerator DisableAR()
{
    XRSettings.LoadDeviceByName("");
    yield return null;
    XRSettings.enabled = false;
}

Then, you can simply call the DisableAR function:

StartCoroutine(DisableAR());

I found this from here.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.