Search Unity

  1. Unity wants to learn about your experiences working on a Unity project today. We'd like to hear from you via this survey.
    Dismiss Notice
  2. Read here for Unity's latest plans on OpenXR.
    Dismiss Notice
  3. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice
  4. Dismiss Notice

Check if ARMeshing supported on device

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

  1. edwon

    edwon

    Joined:
    Apr 24, 2011
    Posts:
    220
    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. KirillKuzyk

    KirillKuzyk

    Joined:
    Nov 4, 2013
    Posts:
    609
    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:
    220
    hmmm I need it in awake, doesn't work on awake
     
  4. KirillKuzyk

    KirillKuzyk

    Joined:
    Nov 4, 2013
    Posts:
    609
    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:
    220
  6. KirillKuzyk

    KirillKuzyk

    Joined:
    Nov 4, 2013
    Posts:
    609
    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
unityunity