Search Unity

Question Loading a new scene during AR session fails

Discussion in 'AR' started by Duckocide, Nov 12, 2020.

  1. Duckocide

    Duckocide

    Joined:
    Aug 30, 2014
    Posts:
    35
    Hi All

    I'm having a little trouble with AR Foundation 4.0.9 in Unity 2020.1 (using AR Core). I'm getting the following error when I load a scene:

    AndroidPlayer(Sony_H8416@192.168.0.193) InvalidOperationException: Can't call "GetChanges" without "Start"ing the anchor subsystem!

    Now to explain what I'm doing:

    1. Initial scene has AR Session and required management scripts.
    2. Detects planes and uses the MakeContentAppearAt() etc to place things.
    3. I move all important AR Session (as I can see it) game objects etc into Don't Destroy (they are all in a hierarchy). This includes the AR Session script instances, camera, etc etc. Basically, looking to keep the AR Session alive when I load a new scene.

    (all Working fine - It's an initial game level with items spread on an AR plane)

    4. A collider trigger in the game causes a new scene to load (next level if you will). It's an additive scene load that waits for the scene to properly load (Coroutine) before current scene unload.

    5. Repeated error in console window and screen freeze (although the game is essentially running - AR camera etc frozen).

    AndroidPlayer(Sony_H8416@192.168.0.193) InvalidOperationException: Can't call "GetChanges" without "Start"ing the anchor subsystem!

    Confused by it as the original AR Plane Manager, Anchor etc is all in the "Do Don't Destroy" camp.

    Any thoughts what I might be doing wrong? I'm getting concerned you can't load a new scene when using AR Foundation.
     
  2. KyryloKuzyk

    KyryloKuzyk

    Joined:
    Nov 4, 2013
    Posts:
    1,142
    I have just created a small example project with your scenario and everything works fine: I was able to load a new scene while persisting ARSession, detected planes, and placed anchors from the previous scene.

    But I've encountered the 'Can't call GetChanges' error in a different scenario, maybe it will help you track down your issue. Here are the steps that cause this error for me:
    1. Enable ARAnchorManager.
    2. Call LoaderUtility.Deinitialize().
    3. Reload current scene.
    I fixed the error by turning off the ARAnchorManager before deinitializing current XR loader.
     
  3. Duckocide

    Duckocide

    Joined:
    Aug 30, 2014
    Posts:
    35
    Thanks @KirillKuzyk - Yep, I managed to get things working as well. Turned out to be a string of null reference exceptions and not fully waiting for the old scene to fully unload. Thanks for this though, very useful!