Detect NReal glasses connection in separate scene

I would like users to be able to launch our app without having the glasses connected (ie: without having to go through Nebula for AR features), then have them select a button to move experience onto NReal glasses.

In separate scenes in Unity, this works for the most part. However, if the glasses are not connected, when arriving at a scene that utilizes NReal features, the app will crash. Is there a way in the previous scene (without NReal features) to gracefully detect whether or not the glasses are connected in order to prevent a crash when arriving at scenes that use NReal features?

Hi developer. Currently, our Nebula doesn’t support this kind of function. But your suggestion is good, we will take this into consideration.

The issue would be that MR features won’t work unless they are launched within Nebula

Very late to this, but I needed to solve this today (basically launch my game in a regular Unity scene) then detect if the glasses are connected to choose whether I go to an AR foundation scene or an Nreal scene. Here is the method I made to check if the glasses are connected:

    public static bool IsGlassesConnected()
    {        
        if (AndroidJNI.AttachCurrentThread() == 0)
        {             
                return new AndroidJavaClass("com.unity3d.player.UnityPlayer")
                    .GetStatic<AndroidJavaObject>("currentActivity")
                    .Call<AndroidJavaObject>("getSystemService", new object[] { "usb" })
                    .Call<AndroidJavaObject>("getDeviceList")
                    .Call<AndroidJavaObject>("values")
                    .Call<AndroidJavaObject[]>("toArray")
                    .Any(x => x.Call<int>("getProductId") == 2313); // RGB camera Id    
        }

        return false;
    }

Basically just checks the USB devices and whether one of them has the RGB camera product ID. I am sure there are things that could go wrong, but if you need a quick check, this seems to work.

I then use it like this in my launch scene:

        if (IsGlassesConnected())
        {
            SceneManager.LoadScene("NrealScene");
        }
        else
        {
            SceneManager.LoadScene("PhoneScene");
        }
2 Likes

Just back on this. I’ll give this a go thanks.

Not sure if this is still any use, but finally got a sample published that creates a single APK supporting both Nreal and ARCore - selecting the scene based on whether the glasses are connected at launch:

martinpgrayson/nreal-multi-platform (github.com)

2 Likes