I wanna make AR and non AR version for android with AR Foundation
(Unity 18.3 ,ARF-1.5 prev.5, ARCore -2.1 p.5, ARKit - 2.1 p.5 as well )
So i want to check platform is supporting AR or not for implimintation diffrent logics .
I tried to use sample for device support check About AR Foundation | AR Foundation | 2.1.19
on Non AR scene.
But anyway on devices that have android version 7 whitch are not support ARCore every launch it
redirect to play market to instal ARCore despite it is dont support it. Only then i close redirect tab it say that device dont support but this redirect happens every launch.
Devices : xiaomi redmi 6a and Huawei Y9 2018.
Also i tried to turn off attemp update option and in project settings make ARcore+Arkit is optional.
Anyone know a solution?
In my experience, there is no guarantee that ‘Google Play Services for AR’ is installed on supported devices automatically. Also, a user can remove this service manually. In these cases, your script will produce a false negative result.
I prefer to use this AR Foundation API to determine the support. It will work correctly only if ARCore is set to ‘Optional’ in XR Plug-in Management.
using System.Collections;
using UnityEngine;
using UnityEngine.XR.ARFoundation;
public class CheckAvailability : MonoBehaviour {
IEnumerator Start() {
yield return ARSession.CheckAvailability();
Debug.Log($"ARSession.CheckAvailability() finished with state: {ARSession.state}");
// ARSession.CheckAvailability() can finish with state ARSessionState.Installing if an update for AR Services is required. So we wait.
while (ARSession.state == ARSessionState.Installing) {
yield return null;
}
if (ARSession.state == ARSessionState.NeedsInstall) {
Debug.Log("Installing AR provider...");
yield return ARSession.Install();
}
Debug.Log($"AR is supported in this device: {ARSession.state >= ARSessionState.Ready}");
}
}
The method with ARSession.CheckAvailability() returns false positive result on some devices and redirects devices that are not supported AR to the Google Play, what is frustrated for users. You can see such behaviour on Redmi Note 5 and some other Xiaomi devices. On the other hand on the most devices this package is undeletable and preinstalled.