Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  3. Read here for Unity's latest plans on OpenXR.
    Dismiss Notice

Checking for AR availability BEFORE launching AR scene?

Discussion in 'AR' started by Saicopate, Nov 5, 2018.

  1. Saicopate

    Saicopate

    Joined:
    Sep 25, 2017
    Posts:
    72
    I am trying to build some logic to test the device after app start to decide whether to allow for AR scene or only conventional 3D scene.
    I know we can use
    ARSubsystemManager.systemState
    to check that but this works only when AR Session component is present in the scene, which means that there needs to be an attempt to initialize AR Session.
    This is pretty expensive task that I would like to avoid straight after launching the app.

    Is there any way around?
     
  2. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    602
    Checkout ARSubsystemManager.checkAvailability(). It is meant to be run as a coroutine (see ARSession.Initialize for an example).

    On Android, the availability check can take several frames because if ARCore is not installed already (or the app the requires a newer version of ARCore), then it has to check with the Play Store to see if there is a version of ARCore which supports that particular device.

    Note that when deploying an ARCore required app from Unity (e.g., click "Build and Run"), unsupported devices will be reported as supported because the Play Store would not have allowed the app to be installed on an unsupported device in the first place.
     
  3. Saicopate

    Saicopate

    Joined:
    Sep 25, 2017
    Posts:
    72
    Thanks Tim, I tried ARSubsystemManager.checkAvailability() in a coroutine but is doesn't work unless AR Session is initilized - systemState is returning "Unsupported". When checking systemState in AR-enabled scene it works ok.

    I guess it is due to these lines of code inside ARSubsystemManager.checkAvailability():

    Code (CSharp):
    1.             if (sessionSubsystem == null)
    2.             {
    3.                 systemState = ARSystemState.Unsupported;
    4.             }
    For me this means you need to try to initialize AR Session first to check whether it will work.
    Of course I am considering this for an "AR-optional" app, where depending on the device compatibility the user is given either 3D-only or 3D+AR options.
     
  4. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    602
    You'll need to call ARSubsystemManager.CreateSubsystems() before you check availability (basically copy what ARSession.OnEnable does).
     
  5. Saicopate

    Saicopate

    Joined:
    Sep 25, 2017
    Posts:
    72
    Ended up doing like you said, thanks!
     
  6. christougher

    christougher

    Joined:
    Mar 6, 2015
    Posts:
    543
    Hi @Saicopate, would you be willing to share what you did to establish AR availability? Thx!
     
    newguy123 likes this.
  7. Saicopate

    Saicopate

    Joined:
    Sep 25, 2017
    Posts:
    72
    Sure.
    I run this at the start of non-AR scene (replace Debug.Log with your own implementation).

    Code (CSharp):
    1.    
    2. private void OnEnable()
    3.     {
    4.         ARSubsystemManager.CreateSubsystems();
    5.         StartCoroutine(ARSubsystemManager.CheckAvailability());
    6.         StartCoroutine(AllowARScene());
    7.     }
    8.  
    9. IEnumerator AllowARScene()
    10.     {
    11.         while (true)
    12.         {
    13.             while (ARSubsystemManager.systemState == ARSystemState.CheckingAvailability ||
    14.                 ARSubsystemManager.systemState == ARSystemState.None)
    15.             {
    16.                 Debug.Log("Waiting...");
    17.                 yield return null;
    18.             }
    19.             if (ARSubsystemManager.systemState == ARSystemState.Unsupported)
    20.             {
    21.                 Debug.Log("AR unsupported");
    22.                 yield break;
    23.             }
    24.             if (ARSubsystemManager.systemState > ARSystemState.CheckingAvailability)
    25.             {
    26.                 Debug.Log("AR supported");
    27.                 yield break;
    28.             }
    29.         }      
    30.     }
    31.  
     
    sameel and christougher like this.
  8. GreeneMachine

    GreeneMachine

    Joined:
    Jul 3, 2015
    Posts:
    126
    Hi
    Implemented the solution above.. appears to be working thanks @Saicopate && @tdmowrer

    One question.. if using this check in non AR main menu... should I use

    Code (CSharp):
    1. ARSubsystemManager.DestroySubsystems()
    .. after I have completed the check and before I load into my AR scene? as per ARSession?

    Or will these subsystems get destroyed gracefully when I unload the main menu scene and load the new AR scene?

    Thanks
     
  9. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    602
    You shouldn't need to destroy it in your case since you are about to start an AR scene. It is safe to call
    ARSubsystemManager.CreateSubsystems()
    multiple times (the second time is effectively a no-op).

    If you did not immediately start your AR scene, then you might want to call
    DestroySubsystems
    just to make sure you cleanly shut down the AR session.
     
    Miguel1691 and GreeneMachine like this.
  10. GreeneMachine

    GreeneMachine

    Joined:
    Jul 3, 2015
    Posts:
    126
    hey @tdmowrer

    I have my ARCore Optional app working on devices that do not support arcore etc. And use the above logic to enable AR within my game.

    How would I do same for IOS? Such that my app will be made available to all devices running target IOS ver 11... whether they support ARKit or not.. and then allow the logic above to control enabling/disabling AR within my game.

    Thanks
     
  11. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    602
    There is a similar setting for ARKit, see the "ARKit Required" section of https://docs.unity3d.com/Packages/c...ual/index.html#creating-a-arkitsettings-asset
     
  12. GreeneMachine

    GreeneMachine

    Joined:
    Jul 3, 2015
    Posts:
    126
  13. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    602
    I believe it was added in a later version. 2018.2 is no longer supported, so you'd need to upgrade to 2018.3 to be able to use this feature. Alternatively, you can manually set it in Xcode; see https://developer.apple.com/documen...ice_support_and_user_permission?language=objc
     
    GreeneMachine likes this.
  14. christougher

    christougher

    Joined:
    Mar 6, 2015
    Posts:
    543
    How can we update this to work in Unity 2019? ARSubsystemManager and ARSystemState no longer seems to exist.
     
  15. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    602
    rockin likes this.
  16. thesanketkale

    thesanketkale

    Joined:
    Dec 14, 2016
    Posts:
    49
    Hello,

    I tried the "Checking for Device Support" available in the documentation of AR Foundation package. It works in case of supported devices, but in case of unsupported devices it throws below exception and the ARSession.state gets set to 'None':

    E/Unity: DllNotFoundException: UnityARCore
    at (wrapper managed-to-native) UnityEngine.XR.ARCore.ARCoreSessionSubsystem+NativeApi.UnityARCore_session_construct(UnityEngine.XR.ARCore.ARCoreSessionSubsystem/NativeApi/CameraPermissionRequestProviderDelegate)
    at UnityEngine.XR.ARCore.ARCoreSessionSubsystem+Provider..ctor (UnityEngine.XR.ARCore.ARCoreSessionSubsystem subsystem) [0x0000d] in <6d08a2168eb04129816197a2388b8f39>:0
    at UnityEngine.XR.ARCore.ARCoreSessionSubsystem.CreateProvider () [0x00000] in <6d08a2168eb04129816197a2388b8f39>:0
    at UnityEngine.XR.ARSubsystems.XRSessionSubsystem..ctor () [0x00006] in <9721d2a78fbe4e8db7471dffc3f5f1ba>:0
    at UnityEngine.XR.ARCore.ARCoreSessionSubsystem..ctor () [0x00000] in <6d08a2168eb04129816197a2388b8f39>:0
    at (wrapper managed-to-native) System.Reflection.MonoCMethod.InternalInvoke(System.Reflection.MonoCMethod,object,object[],System.Exception&)
    at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in <c044b3

    I am using Unity 2019.1.11, AR Foundation 2.1.1 and I am checking it using below co routine:

    Code (CSharp):
    1. private IEnumerator CheckAvailability()
    2. {
    3.    Debug.Log("ARSession.state: " + ARSession.state);
    4.    if ((ARSession.state == ARSessionState.None) ||
    5.       (ARSession.state == ARSessionState.CheckingAvailability))
    6.    {
    7.       ShowErrorMessage("Started Checking Availability...");
    8.       yield return ARSession.CheckAvailability();
    9.    }
    10.  
    11.    Debug.Log("ARSession.state: " + ARSession.state);
    12.    switch (ARSession.state)
    13.    {
    14.        case ARSessionState.Ready:
    15.            Debug.Log("Supported and installed");
    16.            LoadARCoreScene();
    17.            break;
    18.        case ARSessionState.NeedsInstall:
    19.            Debug.Log("Supported, not installed, requesting installation");
    20.            LoadARCoreScene();
    21.            break;
    22.        case ARSessionState.Installing:
    23.            Debug.Log("Supported apk installing");
    24.            LoadARCoreScene();
    25.            break;
    26.        default:
    27.            Debug.Log("Unsupported Device Not Capable");
    28.            LoadNonARCoreScene();
    29.            break;
    30.    }
    31. }
    @tdmowrer : What am I doing wrong? Please help.
     
    Last edited: Jul 23, 2019
  17. thesanketkale

    thesanketkale

    Joined:
    Dec 14, 2016
    Posts:
    49
    Guys please help. Am I missing anything here?
     
  18. Tarrag

    Tarrag

    Joined:
    Nov 7, 2016
    Posts:
    214
    hey @thesanketkale
    I found signing up to ARSession.stateChanged += ARState; at start worked well for me, also running coroutine CheckARSupportedByMobile at start. hope it helps, cheers

    Code (CSharp):
    1. IEnumerator CheckARSupportedByMobile()
    2.     {
    3.         Debug.Log("State " + ARSession.state);
    4.  
    5.         if ((ARSession.state == ARSessionState.None || ARSession.state == ARSessionState.CheckingAvailability))
    6.         {
    7.             Debug.Log("Checking AR Availability on mobile device");
    8.             yield return ARSession.CheckAvailability();
    9.         }
    10.     }
    11.  
    12.     public void ARState(ARSessionStateChangedEventArgs e)
    13.     {
    14.         switch (ARSession.state)
    15.         {
    16.             case ARSessionState.None:
    17.             case ARSessionState.CheckingAvailability:
    18.                 Debug.Log("AR Session - Looking for availability");
    19.                 break;
    20.             case ARSessionState.Unsupported:
    21.                 Debug.Log("AR Session - not available to this mobile device");
    22.                 break;
    23.             case ARSessionState.NeedsInstall:
    24.                 m_Session.enabled = true;
    25.                 Debug.Log("AR Session - needs to be installed in mobile device ");
    26.                 break;
    27.             case ARSessionState.Installing:
    28.                 m_Session.enabled = true;
    29.                 Debug.Log("AR Session - Installing AR onto mobile device ");
    30.                 break;
    31.             case ARSessionState.Ready:
    32.                 m_Session.enabled = true;
    33.                 Debug.Log("AR Session - supported by mobile device and ready to fire up ");
    34.                 break;
    35.             case ARSessionState.SessionInitializing:
    36.                 m_Session.enabled = true;
    37.                 Debug.Log("AR session is initializing ");
    38.                 break;
    39.             case ARSessionState.SessionTracking:
    40.                 Debug.Log("AR Session is tracking");
    41.                 break;
    42.             default:
    43.                 Debug.Log("AR Session - no switch worked");
    44.                 break;
    45.         }
    46.     }
     
  19. thesanketkale

    thesanketkale

    Joined:
    Dec 14, 2016
    Posts:
    49
    Hi @Tarrag,

    Firstly I must say, thank you for replying. Just after your response, I thought that if the same code was working for you, I must have been doing something wrong in my splash scene or player settings. That's where I figured out that I had added ARSession prefab in my splash screen scene where I was checking the ARCore availability. I had added it thinking that while using ARSession.CheckAvailability() the ARSession object might need initialization via a gameobject in the scene. But apparently I was mistaken as CheckAvailability() being a static coroutine, does not need the ARSession to be initialized. The ARSession script on the ARSession prefab in the scene was actually throwing the exception and not ARSession.CheckAvailability().

    Having removed the ARSession prefab from the splash screen, the ARSession.CheckAvailability() is setting the correct ARSessionState now. Thanks again for the reply.

    Regards,
    Sanket.
     
    Tarrag likes this.
  20. badjano

    badjano

    Joined:
    Aug 2, 2012
    Posts:
    14
    I am getting unsupported when ground plane works... does this work with vuforia? I'm trying to use arfoundation just to check if the device has arcore, becuase vuforia's
    VuforiaRuntimeUtilities.GetActiveFusionProvider isn't working either...
    I'm desperate here...
     
  21. thesanketkale

    thesanketkale

    Joined:
    Dec 14, 2016
    Posts:
    49
    ARFoundation's check for ARcore support does work. You can do as shown in previous threads and it should set the ARSession.state to a valid state after couple of seconds of start of ARSession. Just make sure to keep ARSession active and enabled in the scene when you are doing the check. Once your check is done and if you don't need it (like in your case if you are using vuforia) you can destroy the ARSession gameobject.
     
  22. mitshah

    mitshah

    Joined:
    Jul 3, 2019
    Posts:
    5
    Hi , I am trying the same code to check if the device is supported or not but even in an unsupported device, it opens up the play store to install the ar core service and goes for supported or needs to install case. Any help will be much appreciated.
     
  23. mitshah

    mitshah

    Joined:
    Jul 3, 2019
    Posts:
    5

    Hi @thesanketkale

    If i am trying to implement this code without including ARSession prefab including in my non ar scene. It gives me null ref error at yield return ARSession.CheckAvailability(); line and If i am including the prefab it gives me device supported for coroutine and ar session needs to be installed in switch case for non-supported Ar device. I am finding this bit confusing..can you please guide me on it.
    Thanks in Advance.
     
    Last edited: Sep 30, 2019
  24. thesanketkale

    thesanketkale

    Joined:
    Dec 14, 2016
    Posts:
    49
    Hi @mitshah, It is required to put the ARSession gameobject with ARSession component enabled on it in the scene where you are trying to check if the device supports AR Foundation. Whether the scene is AR or Non-AR, it doesn't matter, if you want to check device support, ARSession needs to start first and then it will return valid state in ARSession.CheckAvailability(); coroutine.

    Now for the issue of unsupported device opening play store to install ARCore, first I want to ask, how did you know if the device is not supported for ARCore? In case if you are following the list mentioned here at Google's website then I would say it does not include all the devices that actually do support ARCore. Maybe the list does not update daily, but I have seen devices coming out of chinese phone companies that support ARCore but not listed there.

    The best way to test if the device supports ARCore is to install some apps that only support running on ARCore supported devices. If they work in your device, your device supports ARCore, even if the device manufacturer didn't say it explicitly in its feature list.

    Now if your "unsupported device" opens ARCore services, it would only mean that your device supports ARCore. In case if the above approach of testing ARCore supported device via installing an ARCore app does not work then you infer that your device is unsupported and the AR Foundation's check is behaving incorrectly. This would mean you need to create a dummy project with a script that just checks device support and logs result on the screen and then raise a bug report to Unity along with the project and necessary details of your device, unity version and AR foundation version.

    Hope this helps.

    Regards.
     
  25. linojon

    linojon

    Joined:
    Aug 25, 2014
    Posts:
    115
    Hello. I get errors on older devices from the built project even without calling ARSession.CheckAvailability(). When the GameObject having my script that calls ARSession.CheckAvailability is disabled in the hierarchy, the build passes Google Play review. But when that GameObject is enabled in hierarchy and i build (yet the calls to my checker are commented out so the app doesnt actually call CheckAvailability), I get the following errors reported. In both cases, all other AR components are on game objects that are disabled in Hierarchy at start and would only get SetActive if AR is available.

    DllNotFoundException: Unable to load DLL 'UnityARCore': The specified module could not be found.
    Stack Trace
    UnityEngine.XR.ARCore.ARCoreReferencePointSubsystem+Provider.UnityARCore_refPoints_start () (at <00000000000000000000000000000000>:0)
    https://developer.cloud.unity3d.com...12d6/crashes/b9f4cc1342d71e6db05a86852fa79c0c

    InvalidOperationException: Can't call "GetChanges" without "Start"ing the reference-point subsystem!
    Stack Trace
    UnityEngine.XR.ARSubsystems.XRReferencePointSubsystem.GetChanges (Unity.Collections.Allocator allocator) (at <00000000000000000000000000000000>:0)
    https://developer.cloud.unity3d.com...12d6/crashes/f7edcf3e72c083d136de39fe6748ad4f

    DllNotFoundException: Unable to load DLL 'UnityARCore': The specified module could not be found
    UnityEngine.XR.ARCore.ARCorePlaneProvider+Provider.UnityARCore_planeTracking_setPlaneDetectionMode (UnityEngine.XR.ARSubsystems.PlaneDetectionMode mode) (at <00000000000000000000000000000000>:0)
    https://developer.cloud.unity3d.com...12d6/crashes/0613bd94a5751fe19c8b94fe26f00a74

    and several more like these.

    Using Unity 2019.3.3f1, ARFoundation 2.1.4, ARCore XR Plugin 2.1.2
    Minimum API Level: Android 4.4 KitKat API level 19
    Target API Level: Automatic (highest installed)
    Scripting Backend: IL2CPP, .NET 4.x
    Target Architectures: ARMv7, ARM64


    It's important that my game support as many Android devices as possible, and the AR feature is enabled, by user turning it on, only on devices that support it. Any help or suggestions are appreciated.
     
    Last edited: Mar 29, 2020
  26. thesanketkale

    thesanketkale

    Joined:
    Dec 14, 2016
    Posts:
    49
    Hi @linojon, first of all I would suggest not keeping the ARSession object in the scene when you don't need it. As a matter of fact, I would suggest not keep any game object related to AR in the scene till you need it. You can keep prefabs of such game objects and instantiate when needed. So, when you want to check if a device supports AR Foundation, just instantiate the ARSession prefab, keep it active and add a delegate to ARSession.stateChanged listener which on calling should give you whether or not the device supports AR Foundation. In case if the device does, you can continue with your AR related game play and if it doesn't, destroy the ARSession object and tell the user that the device does not support AR.

    P.S. - If the game is targeted for non AR supported devices as well, make sure to set ARCore and/or ARkit to Optional in the respective Build Settings.

    Now, about the error, its because your game is trying to start the AR subsystem in unsupported devices where ARCore is not available. This is probably due to enabling the ARSessionOrigin object in the scene in an unsupported device(like an older android device). Just be aware that for checking availability of AR Foundation support, you only require an active ARSession object in the scene and nothing else. If its supported only then instantiate other AR Foundation related game objects like the ARSessionOrigin otherwise make sure your scene does not contain anything related to AR Foundation to save your game from such exceptions.

    Hope it helps.
     
  27. linojon

    linojon

    Joined:
    Aug 25, 2014
    Posts:
    115
    Hi thanks for the quick reply. This is helpful. Since my post I've moved all the AR objects into a separate additive scene and only load it if the user has a supported device and has requested AR features. However, I had read that we should load the app with ARSession component disabled (on an active gameobject), check for availability, and then only then enable the ARSession component if we can/want? However this still produces a null exception error on s_Instance.CreateSubsystemIfNecessary(); because s_Instance is null until Awake is called. I modified the ARSession.cs file as follows

    Code (CSharp):
    1.         public bool _disableOnAwake = true;
    2.  
    3.         void Awake()
    4.         {
    5.             s_Instance = this;
    6.             s_NotTrackingReason = NotTrackingReason.None;
    7.  
    8.             if (_disableOnAwake)
    9.             {
    10.                 s_Instance.enabled = false;
    11.             }
    12.         }
    13.  
    The reason is i still dont want it to call ARSession#OnEnable (including the Install() stuff) unless/until the user has requested to turn on AR features.

    My app now seems to pass the Google Play Review (yaay!). If there's a better way to achieve this (only check Unsupported) with no other actions by the ARSession, can you please clarify with specific code? Thanks!
     
  28. thesanketkale

    thesanketkale

    Joined:
    Dec 14, 2016
    Posts:
    49
    Well, if you just want to check for AR support in a device, you can try this:

    Code (CSharp):
    1. public GameObject ARSessionPrefab;
    2.  
    3. private GameObject ARSessionObj;
    4. private bool isARSupported;
    5.  
    6. private void Start()
    7. {
    8.    StartCoroutine(CheckAvailability());
    9. }
    10.  
    11. private IEnumerator CheckAvailability()
    12. {
    13.    if (!ARSessionObj)
    14.    {
    15.        ARSessionObj = Instantiate(ARSessionPrefab);
    16.        yield return new WaitForSecondsRealtime(1);
    17.    }
    18.    if (!Application.isEditor)
    19.    {
    20.        Debug.Log("ARSession.state: " + ARSession.state);
    21.        switch (ARSession.state)
    22.        {
    23.            case ARSessionState.CheckingAvailability:
    24.                Debug.Log("Still Checking Availability...");
    25.                ARSession.stateChanged += ARSessionStateChanged;
    26.                break;
    27.            case ARSessionState.NeedsInstall:
    28.                Debug.Log("Supported, not installed, requesting installation");
    29.                //TODO: Request ARCore services apk installation and install only if user allows
    30.                StartCoroutine(InstallARCoreApp());
    31.                break;
    32.            case ARSessionState.Installing:
    33.                Debug.Log("Supported, apk installing");
    34.                StartCoroutine(InstallARCoreApp());
    35.                break;
    36.            case ARSessionState.Ready:
    37.                Debug.Log("Supported and installed");
    38.                NextStep(true);
    39.                break;
    40.            case ARSessionState.SessionInitializing:
    41.                Debug.Log("Supported, apk installed. SessionInitializing...");
    42.                NextStep(true);
    43.                break;
    44.            case ARSessionState.SessionTracking:
    45.                Debug.Log("Supported, apk installed. SessionTracking...");
    46.                NextStep(true);
    47.                break;
    48.            default:
    49.                Debug.Log("Unsupported, Device Not Capable");
    50.                NextStep(false);
    51.                break;
    52.        }
    53.    }
    54.    else
    55.    {
    56.        Debug.Log("Unity editor: AR not supported, Device Not Capable");
    57.        NextStep(false);
    58.    }
    59. }
    60.  
    61. private void ARSessionStateChanged(ARSessionStateChangedEventArgs obj)
    62. {
    63.    Debug.Log("Inside ARSessionStateChanged delegate...");
    64.    switch (ARSession.state)
    65.    {
    66.        case ARSessionState.CheckingAvailability:
    67.            Debug.Log("Still Checking Availability...");
    68.            break;
    69.        case ARSessionState.NeedsInstall:
    70.            Debug.Log("Supported, not installed, requesting installation");
    71.            //TODO: Request ARCore services apk installation and install only if user allows
    72.            StartCoroutine(InstallARCoreApp());
    73.            break;
    74.        case ARSessionState.Installing:
    75.            Debug.Log("Supported, apk installing");
    76.            StartCoroutine(InstallARCoreApp());
    77.            break;
    78.        case ARSessionState.Ready:
    79.            Debug.Log("Supported and installed");
    80.            NextStep(true);
    81.            break;
    82.        case ARSessionState.SessionInitializing:
    83.            Debug.Log("Supported, apk installed. SessionInitializing...");
    84.            NextStep(true);
    85.            break;
    86.        case ARSessionState.SessionTracking:
    87.            Debug.Log("Supported, apk installed. SessionTracking...");
    88.            NextStep(true);
    89.            break;
    90.        default:
    91.            Debug.Log("Unsupported, Device Not Capable");
    92.            NextStep(false);
    93.            break;
    94.    }
    95. }
    96.  
    97. private IEnumerator InstallARCoreApp()
    98. {
    99.    yield return ARSession.Install();
    100.    NextStep(true);
    101. }
    102.  
    103. private void NextStep(bool IsARSupported)
    104. {
    105.    ARSession.stateChanged -= ARSessionStateChanged;
    106.    if (ARSessionObj)
    107.    {
    108.        Destroy(ARSessionObj);
    109.    }
    110.    //TODO: Well, continue your game play according to the AR Support boolean or maybe load the AR specific scene
    111. }
     
    ansyal2006 and linojon like this.
  29. linojon

    linojon

    Joined:
    Aug 25, 2014
    Posts:
    115
    Thanks again! Very helpful, and works. I made a stripped down version for my needs (with switch statements like this). It's just for deciding whether to present an AR option in the UI. The full CheckAvailablity is done only if the player then tries to enable the AR settings.

    Code (CSharp):
    1.         switch (ARSession.state)
    2.         {
    3.             case ARSessionState.CheckingAvailability:
    4.                 ARSession.stateChanged += _ARSessionStateChanged;
    5.                 break;
    6.  
    7.             case ARSessionState.NeedsInstall:
    8.             case ARSessionState.Installing:
    9.             case ARSessionState.Ready:
    10.             case ARSessionState.SessionInitializing:
    11.             case ARSessionState.SessionTracking:
    12.                 _isARSupportChecked = true;
    13.                 _isARSupported = true;
    14.                 _DoneChecking();
    15.                 break;
    16.  
    17.             default:
    18.                 _isARSupportChecked = true;
    19.                 _isARSupported = false;
    20.                 _DoneChecking();
    21.                 break;
    22.         }
     
  30. SUYAL

    SUYAL

    Joined:
    Aug 12, 2018
    Posts:
    2
    @linojon @thesanketkale Thanks for great help,

    While checking AR compatibility in non-AR supported android devices, I am being moved to Google Play Services for AR in playstore where it is shown that device is not compatible. But I wanted to know if I need to change something in code or something so that I can know beforehand if device is not compatible and act accordingly. I wish to know AR compatibility without visiting playstore, and if install is required on compatible devices then move to playstore.
    Please help if there is any way to do so.

    Thanks!
     
  31. thesanketkale

    thesanketkale

    Joined:
    Dec 14, 2016
    Posts:
    49
    Well, this should not happen unless you have checked 'Attempt Update' in ARSession component to true. If your AR implementation is optional, then you should not check that and handle updating Google ARCore Services app in your code only if its compatible.

    ar-session.png
     
    linojon likes this.
  32. SUYAL

    SUYAL

    Joined:
    Aug 12, 2018
    Posts:
    2
    Thanks for the quick and crisp response. It really helped and solved the issue, you are great!
     
unityunity