unity-game-enginegoogle-apigeospatialarcorear-foundation

Only if VPS is available with ARCore-API unloading an additive scene is not destroying its GameObjects


I'm currently testing my geospatial app that connects to the Google ARCore API. I add scenes additively to my main scene, but when I unload them, the GameObjects stay where they are, even if the UnloadSceneAsync operation completes successfully. Strangely, this only happens when the app is connected to the ARCore API. If I disable the API in Google Cloud Console (so the app can only use GPS and IMU for positioning) everything unloads correctly.

I tried unloading unnecessary assets using Resources.UnloadUnusedAssets() after I unload a scene. I tried disabling the ARSession before unloading the scene and re-enabling it afterwards. I tried to destroy all Geospatial Creator Anchors before unloading their scene in case the ARSession or EarthManager would not allow to unload these objects.

Further information: This happens both on Android and iOS. I do not know how to use the VPS capability inside the Unity Editor, so I can only see this result on the phones.

I noticed that the scene unloading is working when the ARSession did not initialize correctly (happened sometimes if the Android Resolver did not build the project correctly).

Everytime a scene is loaded or unloaded the operation happens async and they are all waiting for the previous operation to end.

The ARSession is loaded and initialized with the second scene. The first scene always remains and stays the active scene. After the second scene is loaded, several additional small scenes containing Geospatial Creator anchors can be selected and loaded.


Solution

  • The ARAnchorManager automatically parents every GameObject with an ARAnchor or ARGeospatialAnchor to a 'Trackables' GameObject underneath the AR Session Origin. So it also moves GameObjects in between additively added scenes. Following this documentation I just deleted all GameObjects with such a component before unloading the old scene and loading the new scene.

    I just still do not understand why this is only happening when the ARCore API is connected.