Unity ARFoundation unable to find ARCameraBackground

Viewed 735

I am attempting to compile an android build of an AR Scene using Unity's AR Foundation Package, and ARCore.

Everything works except actually getting the camera feed from my mobile device, and running the build in editor returns the error:

NullReferenceException: Object reference not set to an instance of an object
UnityEngine.XR.ARFoundation.ARCameraBackground.OnDisable () (at Library/PackageCache/com.unity.xr.arfoundation@2.2.0-preview.2/Runtime/AR/ARCameraBackground.cs:192)

I've looked into the script it's claiming to have errors with and the error appears to be originating from this block:

void OnEnable()
        {
            UpdateMaterial();
            m_CameraManager.frameReceived += OnCameraFrameReceived;
            ARSession.stateChanged += OnSessionStateChanged;
        }

I'm unsure as to where this error is coming from beyond the camera itself potentially not being able to find the material source somehow? The same error also returns upon closing the application, in this code block:

void OnDisable()
        {
            mode = ARRenderMode.StandardBackground;
            m_CameraManager.frameReceived -= OnCameraFrameReceived;
            ARSession.stateChanged -= OnSessionStateChanged;
            m_CameraSetupThrewException = false;

            // We are no longer setting the projection matrix
            // so tell the camera to resume its normal projection
            // matrix calculations.
            m_Camera.ResetProjectionMatrix();
        }

I'm struggling to work out as to why AR Foundation is unable to identify the source of the camera feed, and i've done quite a bit of googling into this problem. When attempting to run it on a device, it asks for camera permission however the feed never displays.

0 Answers
Related