Null Refrence Exception in ARSessionExtensions when running in editor
With Android selected as the platform, I get an NullReferenceException every frame when running in editor.
NullReferenceException: Object reference not set to an instance of an object
Google.XR.ARCoreExtensions.Internal.ARSessionExtensions.SessionHandle (UnityEngine.XR.ARFoundation.ARSession session) (at Library/PackageCache/com.google.ar.core.arfoundation.extensions@a6a358c9d6f4-1585901453915/Runtime/Scripts/Internal/ARCoreHandles/ARSessionExtensions.cs:32)
Google.XR.ARCoreExtensions.ARCoreExtensions.Update () (at Library/PackageCache/com.google.ar.core.arfoundation.extensions@a6a358c9d6f4-1585901453915/Runtime/Scripts/ARCoreExtensions.cs:146)
This can be fixed in ARCoreExtensions by adding a UNITY_EDITOR preprocessor directive. Could someone with repo permissions review/fix?
ARCoreExtensions.cs line 142:
public void Update()
{
#if UNITY_ANDROID && !UNITY_EDITOR
// Ensure Cloud Anchors are enabled or disabled as requested.
IntPtr sessionHandle = Session.SessionHandle();
if (sessionHandle != IntPtr.Zero)
{
SessionApi.EnableCloudAnchors(
sessionHandle,
ARCoreExtensionsConfig.EnableCloudAnchors);
}
#endif
}
Thanks for the report.
Thank you for the report, we have fixed this in our next release.
I was having this same problem and used this fix, which got rid of the NullReferenceException. Now I have a "SessionApi does not contain a definition for EnableCloudAnchors" error. I tried changing to CloudAnchorMode but same issue. Am I missing something?
SessionApi.EnableCloudAnchors() has been removed since v1.19 as part of deprecation of ARCoreExtensionsConfig.EnableCloudAnchors which was done in v1.20.