We’re building an app that shall support various platforms (Android, iOS, visionOS), so we want to check the existence of AR subsystems.
For Face Tracking, we use this approach:
var descriptors = new List<XRFaceSubsystemDescriptor>();
SubsystemManager.GetSubsystemDescriptors(descriptors);
if (descriptors.Any()) faceTrackingDescriptor = descriptors.First();
This works reliably, even in Unity Editor, where faceTrackingDescriptor
is null, as expected.
However, if we try this for Image Tracking:
var descriptors = new List<XRImageTrackingSubsystemDescriptor>();
SubsystemManager.GetSubsystemDescriptors(descriptors);
if (descriptors.Any()) imageTrackingDescriptor = descriptors.First();
it returns a descriptor even in Unity Editor, indicating that Image Tracking should work here.
However, as soon as I call CreateRuntimeLibrary()
on the ARTrackedImageManager
, Unity throws an exception:
No image tracking subsystem found. This usually means image tracking is not supported.
This is super confusing. I assume this is a bug in ARFoundation. Is there another, more reliable (and non-hacky) way to detect if Image Tracking is available?
Edit: I found out that the property .descriptor
on the ARTrackedImageManager
itself is null in this case. However, on iOS, this is also null until I call CreateRuntimeLibrary
on it. Then, the descriptor magically becomes available.