Quest / File Picker won't unpause

I’ve been faffing around for ages with this trying to get a solution, and keep getting to the same sticking point. I’m using Unity 6 LTS, on an apple silicone Mac and developing for Quest 3.

I need to grant permissions (done) and choose a file or folder from local storage (eventually a USB plugged into the headset but am testing with local DCIM etc as well).

After jumping through many iterations my latest attempt is using Native File Picker for Android & iOS | Integration | Unity Asset Store

It pops up fine. I can choose a file fine. But then - stop. Black screen. The application is paused. If I hit the oculus button it unpauses - but nothing I can do can force it to do this without pressing the oculus button.

This is my “triggering” code:

            Debug.Log("Just trying to load video from USB!");
            string[] fileTypes = new string[] { "image/*", "video/*" };
            NativeFilePicker.Permission permission = NativeFilePicker.PickMultipleFiles( ( paths ) =>
			{
				if( paths == null )
					Debug.Log( "Operation cancelled" );
				else
				{
					for( int i = 0; i < paths.Length; i++ )
						Debug.Log( "Picked file: " + paths[i] );
				}
                // Force XR restart immediately after the file picker
                Debug.Log("Restarting XR after file picker...");
                StartCoroutine(RestartXR());
			}, fileTypes );
			Debug.Log( "Permission result: " + permission );

The co-routine (which I added afterwards) after reading around lots is this:

    IEnumerator RestartXR()
    {
        Debug.Log("Stopping XR...");
        XRGeneralSettings.Instance.Manager.StopSubsystems();
        Debug.Log("XR stopped.");

        // Allow the system to settle
        yield return new WaitForEndOfFrame();

        Debug.Log("Starting XR...");
        XRGeneralSettings.Instance.Manager.StartSubsystems();
        Debug.Log("XR restarted.");

        // Reactivate the camera
        EnsureCameraIsActive();
    }

but nothing in the callback is called until after I unpause with the oculus button.

I’ve also tried forcing it (though I don’t want this as a solution as I want to be able to pause deliberately!)

    void OnApplicationPause(bool pause)
    {
        Debug.Log($"Application pause state changed. Paused: {pause}");
        if (pause)
        {
            Debug.Log("Unity is paused, forcing activity to resume...");
            BringUnityToForeground(); // Forces Unity back to the foreground
        }
    }

and

    void BringUnityToForeground()
    {
        using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
        {
            AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
            currentActivity.Call("runOnUiThread", new AndroidJavaRunnable(() =>
            {
                Debug.Log("Forcing Unity activity to resume...");
                currentActivity.Call("onResume");

                // Explicitly restart XR after onResume
                Debug.Log("Restarting XR after forcing activity to resume...");
                StartCoroutine(RestartXR());
            }));
        }
    }

but that doesn’t seem to actually unpause either!

I’m tearing what’s left of my hair out. I’m still learning (lots) but when things just “don’t work” like this it can be so confusing!

If you have trouble with the permissions dialog not returning, I can check out our code. We use that as well and it works properly.

If the issue is with the native selection dialog, I would suspect that the asset you linked has not been tested on Quest and has some internal assumptions which lead to the behaviour you are seeing. We allow users to select files as well, but we show the file system using our own UI. That works out (obviously) and, in our use case, was a better UI choice.

One thing you might want to check is whether there is any option of choosing a file through Oculus/Meta API (I’m not sure if there is).

I kind of “made do” - figuring I’d deal with it later. But have since run into a bigger problem - it only lets you choose a file - I need to be able to access all the files in the same folder (which will be videos).

I’m not sure what to do to be honest. I’ll try and look throug the Meta API but I’m kind of flying blind!

Happy to share code if you have any ideas (though as above I’ve moved pat that bit now)

As I don’t know the File Picker asset, I can’t say anything about selections there (is it not possible to just select a folder instead of a file?).

But I suspect that if you want complete configuration, you need to just implement your own file selection in your own UI. Just read the files using the standard API (C#: DirectoryInfo) and put them in a listview or similar for selection.

It’s my understanding that Android blocks the standard API using SAF.

I’ve given up on file picker - so am going to open a new more focussed thread.

It’s a known issue that Meta has broken support for SAF, where you are required to use native OS popups. Basically the callback isn’t triggered even when permission is granted, we found that sleep/waking the Quest appears to trigger it though.

We’ve been given no timeline for a fix, and that was 2 years ago. We were forced to ask and use the MANAGE_EXTERNAL_STORAGE permission to do it the old way, which understandably spooks users.

Interesting, I wasn’t aware of an issue with SAF. Can you share a link?

As said above, we’re using the plain variant (i.e. the C# File API), having declared READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE. That works out fine for us.

Philip