Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question How does CheckAvailability() work?

Discussion in 'AR' started by mitch547, Mar 22, 2022.

  1. mitch547

    mitch547

    Joined:
    Dec 21, 2021
    Posts:
    2
    Hello!

    I'm working on my AR app. So, before starting any AR action I want to check if the device supports AR features.
    I looked how it's done in AR Foundation Samples (https://github.com/Unity-Technologies/arfoundation-samples), I tested it on my phone and it works well.
    So, I decided to implement similar algorithm in my app. What I got is that it works a bit differently than the 'Check Support' sample.
    The difference is that the sample app checks for AR support almost immediately as the sample starting, without even requiring some camera frames.
    My code can't get ARSessionState.Ready if the camera view is blocked by something (and we see a dark screen). ARSessionState is always equal to SessionInitializing.
    There is also some difference in my code and sample code. Sample app consists of couple different scenes, and ARSession.CheckAvailability() starts just when the scene starts. My code has single scene, and CheckAvailability() might be called anytime later while the app running.

    The question is how to deal with this kind of behaviour in my app (checking requires camera frames). Can I achieve the same behaviour as in the sample app without creating separate scene to check AR support? Should I really wait ARSessionState to become Ready to be sure that device supports AR features? Or does SessionInitializing already mean that AR works well on my device?

    Thanks!
     
  2. mitch547

    mitch547

    Joined:
    Dec 21, 2021
    Posts:
    2
    Just got the idea that my app also uses Image Tracker. Probably my code somehow skips that moment when ARSessionState == Ready and immediately becoming SessionInitializing/SessionTracking, because Image Tracker is running.
    Did I understand the idea of ARSessionState correctly?
     
  3. todds_unity

    todds_unity

    Unity Technologies

    Joined:
    Aug 1, 2018
    Posts:
    324
    mitch547 likes this.