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

Question Second time entering the scene the Camera doesn't recognize images

Discussion in 'AR' started by game4tress, Oct 19, 2022.

  1. game4tress

    game4tress

    Joined:
    May 13, 2010
    Posts:
    46
    Hi,

    I'm using the "XR Plugin" on an Android App.
    I have several scenes but only one uses AR.
    The first time I go into the scene using AR, the image is recognized and a 3D object appears as it is supposed to, however if I go into another Scene, when I come back to the one using AR, the object that was previously recognized is no longer. If I instead use another image / object it works as long as I stay in that scene (because if I leave and come back again, the same will happen to that object / image).
    I have used several images and several 3D objects to test, all of them with the same behaviour.
    One interesting detail is that the first time I enter the AR scene the camera looks well, but the next time it looks like it's not focusing properly as if it was focusing on a specific spot.
    Based on my google search for this issue I started using the following code on the Start() event of the Scene
    ARSession.Reset();
    ARSession.enabled = true;
    But I still have the same problem
    If I exit the app and enter again, once again, for the first time it all works fine.
    Can you please help?

    My thanks in advanced
     
  2. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,025
  3. game4tress

    game4tress

    Joined:
    May 13, 2010
    Posts:
    46
    Thank you for your response.
    I believe I found the issue through this page:
    https://forum.unity.com/threads/loading-and-unloading-scenes.461169/
    It works with:
    SceneManager.LoadScene
    and
    SceneManager.LoadSceneAsync("SceneToBeLoaded", LoadSceneMode.Single);

    Previously I was just doing:
    SceneManager.LoadSceneAsync("SceneToBeLoaded");
    This is where it fails and the 3D object is rendered only on the first time the scene loads.

    Thank you
     
    andyb-unity likes this.