unity-webxr-export icon indicating copy to clipboard operation
unity-webxr-export copied to clipboard

Subsystem null?

Open dracolytch opened this issue 4 years ago • 3 comments
trafficstars

In the XRState, the code was accessing subsystem.xrState. However, in my case (I have no idea why) subsystem was null. This was causing a NullRefEx every frame, and nothing worked. I replaced the existing code with the following as a workaround, but I have no idea if I actually broke anything, since I don't know the origin of the subsystem. Maybe there should be an "Unknown" or "Uninitialized" value in the enum if the subsystem hasn't been instantiated yet?

~D

WebXRManager.cs line 18 changed to the following:

    public WebXRState XRState
    {
        get
        {
            if (subsystem == null) return WebXRState.NORMAL;
            return subsystem.xrState;
        }
    }

dracolytch avatar Jun 29 '21 19:06 dracolytch

The WebXR Subsystem can't be initialize in the editor, because, well, you are in the editor and not in a supported browser :) But in runtime it does work.

It's a repeating issue. So I guess we should handle it better. For the WebXRController we use the available XR input if we are not in WebGL runtime.

So one option is to try and also emulate the WebXRManager in the editor, and the other is returning stub values like you did.

De-Panther avatar Jun 29 '21 19:06 De-Panther

There's an open source XR mock / emulator for ARFoundation, not sure how things go with what you say and something like that, did test it the other day with some success. https://github.com/coder89/arfoundation-mock

antont avatar Sep 14 '21 22:09 antont

Interesting find @antont , thanks!

De-Panther avatar Sep 16 '21 05:09 De-Panther

Forgot to close this issue when it was fixed (6 months ago).

De-Panther avatar Apr 15 '23 05:04 De-Panther