Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

ARFoundation: What causes a subsystem to be null?

Discussion in 'AR/VR (XR) Discussion' started by Numa, Sep 7, 2019.

  1. Numa

    Numa

    Joined:
    Oct 7, 2014
    Posts:
    100
    Hi,

    I'm looking for some clarification on how subsystems work in ARFoundation. I can't find anything definitive in the doc.

    1.What causes a subsystem to be null?
    2. Is it safe to check if a subsystem is null just once in a Start() function? In some of the examples I see it's getting checked in an update loop. Do they take time to "turn on"? Can they randomly be null on a frame?
    3. Is it safe to use subsystem != null to check feature support? In the ARCollaboration sample scene I found this code which doesn't work at all:
    Code (CSharp):
    1. void Update()
    2.     {
    3.         var subsystem = m_HumanBodyManager.subsystem;
    4.         if (subsystem == null)
    5.         {
    6.             if (m_ImageInfo != null)
    7.             {
    8.                 m_ImageInfo.text = "Human Segmentation not supported.";
    9.             }
    10.             return;
    11.         }
    12. }
    The system isn't null on an old device that definitely doesn't support segmentation. Instead when I check for
    Code (CSharp):
    1. subsystem.SubsystemDescriptor.supportsHumanDepthImage
    I get the right result.

    Some subsystems also have a dedicated support check:
    Code (CSharp):
    1. ARKitSessionSubsystem.supportsCollaboration
    What's the correct way to check if a feature is supported?

    Thanks!