Skip to content

File Browser

Gaurang Ruparelia edited this page Dec 10, 2023 · 3 revisions

File Browser: https://github.com/yasirkula/UnitySimpleFileBrowser https://github.com/yasirkula/UnitySimpleFileBrowser/issues/87 https://github.com/yasirkula/UnitySimpleFileBrowser/issues/89

https://discussions.unity.com/t/vr-oculus-quest-2-unity-file-browser-to-select-and-load-an-image/257860?clickref=1100ly3ZUYAG&utm_source=partnerize&utm_medium=affiliate&utm_campaign=unity_affiliate

This has mainly been done based on the guidance here: https://discussions.unity.com/t/vr-oculus-quest-2-unity-file-browser-to-select-and-load-an-image/257860/5#:~:text=But%20also%20you,VR%20and%20XR.

  1. I have added permissions in the Awake method as advised on the FAQ
  2. I have modified the SimpleFileBrowserCanvas asset to better suit VR by changing the Render mode to World Space
  3. Adjusted the Scale of the prefab to suit the VR environment (e.g., set x, y, and z to 0.0048 or to a scale that fits your VR setup).
  4. Added XRI Input module after enabling the Event System
  5. Added TrackedDeviceGraphicRaycaster to the Event System
  6. Placed the asset in my main scene and hid it initially
  7. Added TrackedDeviceGraphicRaycaster to the Files Canvas nested deep inside, and to SimpleFileBrowserCanvas prefab and the event system
  8. Remove the Camera nested in SimpleFileBrowserCanvas

There are nested canvases (canvases inside SimpleFileBrowserCanvas) that should either be removed (via Remove Component) or their GraphicRaycaster component should be replaced with TrackedDeviceGraphicRaycaster. This should fix the input issue. If you can't see the file browser in your scene, then its Transform component needs more tweaking IMO. Try positioning and scaling it near a 3D object in your scene. You should also remove the camera child object from the prefab, it's not needed and could cause additional issues.

RequestPermission returns Permission.Denied on Android Declare the WRITE_EXTERNAL_STORAGE permission manually in your Plugins/Android/AndroidManifest.xml file with the tools:node="replace" attribute as follows: (you'll need to add the xmlns:tools="http://schemas.android.com/tools" attribute to the <manifest ...> element).

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.GaurangR.Alexandria">

    <!-- Replace the existing WRITE_EXTERNAL_STORAGE permission declaration -->
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="replace" />
    
    <!-- Include the following only if you target Android 10 (API level 29) or higher -->
    <!-- Scoped Storage enforcement bypassed for Android 11 and higher -->
    <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" tools:ignore="ScopedStorage" />

    <application>
        <activity android:name="com.unity3d.player.UnityPlayerActivity"
            android:theme="@style/UnityThemeSelector">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
        </activity>
        <activity android:name="com.unity3d.player.UnityPlayerGameActivity"
            android:theme="@style/BaseUnityGameActivityTheme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
            <meta-data android:name="android.app.lib_name" android:value="game" />
        </activity>
    </application>
</manifest>
Clone this wiki locally