Search Unity

Check if ARMeshing supported on device

Discussion in 'AR' started by edwon, Jun 11, 2020.

  1. edwon

    edwon

    Joined:
    Apr 24, 2011
    Posts:
    266
    Is there a way to check if ARMeshManager (aka Scene Reconstruction on iOS with the new iPad) will work on a given device?

    I need to change some behaviour depending on whether I'm getting planes or meshes from the device (I know you can use both at the same time but it causes issues in my use case)
     
  2. KyryloKuzyk

    KyryloKuzyk

    Joined:
    Nov 4, 2013
    Posts:
    1,142
    You can check if meshing subsystem is created by ARMeshManager manager:

    var isMeshingSupported = FindObjectOfType<ARMeshManager>().subsystem != null;
     
  3. edwon

    edwon

    Joined:
    Apr 24, 2011
    Posts:
    266
    hmmm I need it in awake, doesn't work on awake
     
  4. KyryloKuzyk

    KyryloKuzyk

    Joined:
    Nov 4, 2013
    Posts:
    1,142
    In my experience, you can't check if some AR feature is supported on Awake. You are required to wait until ARSession.state == ARSessionState.Ready and only then you can tell if current device supports specific AR capability.

    If you're running on Android, you also need to account for the case if ARCore is not installed on device and install it with ARSession.Install()
     
  5. edwon

    edwon

    Joined:
    Apr 24, 2011
    Posts:
    266
  6. KyryloKuzyk

    KyryloKuzyk

    Joined:
    Nov 4, 2013
    Posts:
    1,142
    It seems to me I've found a clean solution without the need to use coroutines and wait for ARSession.state >= Ready. It can be even used in Awake().
    Code (CSharp):
    1. public static bool IsMeshSubsystemSupported() {
    2.     var subsystems = new List<XRMeshSubsystem>();
    3.     SubsystemManager.GetInstances(subsystems);
    4.     return subsystems.Any();
    5. }
     
    Last edited: Oct 14, 2020