Oculus Quest 2 Unity



Tutorials // Uncategorized

Solution#1:
– Place your file into some sdcard folder (by browsing there with Explorer), for example:”This PCQuestInternal shared storageDownloadmyfile.txt”
– Add script to load file:
var t = File.ReadAllText('/sdcard/Download/myfile.txt');
– From Unity menu select: Oculus/Tools/Create store-compatible AndroidManifest.xml
– Modify Assets/Plugin/Android/AndroidManifest.xml, add this line after </application> :
<uses-permission android:name='android.permission.READ_EXTERNAL_STORAGE' />
– Build & Run *Note: run fails, due to missing launch action.. so run the app manually in device (from library/unknown sources)
– Allow Read permissions when you start the app

Plug in your Oculus Quest Plug your Quest or Quest 2 into the computer. Put on the headset and accept the two prompts that it gives you about sharing information with the computer.

Optional:
– You can enable LAUNCHER, to make Build & Run work, by replacing this line:
<category android:name='android.intent.category.INFO'/>
with:
<category android:name='android.intent.category.LAUNCHER'/>
– Can also disable permission request (while doing tests), by modifying this line:
meta-data android:name='unityplayer.SkipPermissionsDialog' android:value='false'
into:
meta-data android:name='unityplayer.SkipPermissionsDialog' android:value='true'
– Can also add Write permissions:
<uses-permission android:name='android.permission.WRITE_EXTERNAL_STORAGE'/>

My AndroidManifest.xml:
https://gist.github.com/unitycoder/a8a827311ea0837b06af6ccde85effec

  • VR Co-location-multiplayer plugin for Unity + Oculus Quest (2) A downloadable tool We are Nic and Amelie, two young programmers from Germany, and we are currently working on a Unity plug-in for co-location multiplayer games in virtual reality.
  • Oculus Quest 2 should look familiar, as its design language and general form factor are nearly identical to the original VR system that launched in March 2019 starting at $399.Both versions have.

Solution#2: (temporary fix)
check what permissions the app has:
adb shell dumpsys package <package_name>
then add permissions
adb shell pm grant <package_name> android.permission.READ_EXTERNAL_STORAGE
adb shell pm grant <package_name> android.permission.WRITE_EXTERNAL_STORAGE

Resources:
– https://developer.oculus.com/distribute/latest/concepts/publish-mobile-manifest/
– https://forums.oculusvr.com/developer/discussion/78412/accessing-local-files

Tags: file, oculus, permissions, quest, read, sdcard, unity, vr

Related Posts

10 Comments + Add Comment

  • Hasn’t worked for me.

    I followed the instructions closely, replaced the manifest file with the example provided. I built and run, and then closed the app and opened it from ‘Unknown sources’. I believe it throws an error when running the line

    string testLoadString = File.ReadAllText(“/sdcard/Download/test.txt”);

    Although I don’t know how to see the error once it is not in Unity. Note that, even when I had not included the line

    meta-data android:name=”unityplayer.SkipPermissionsDialog” android:value=”true”

    it still didn’t ask for permissions when running the app.

    Any help would be greatly appreciated.

  • This worked perfectly on Quest 1, BUT not on Quest 2.
    Any idea if the path changed on Quest 2?

    Can pay 50$ via paypal for any insight leading to the solution 🙂

    Thanks
    Felix

  • Any news on if Quest 2 directory has changed? On if there are any new steps involved.

  • I had video file read problems in 2019.1 and it seems to be an Android 10 bug.
    It was solved for me by using Unity 2019.2.
    https://issuetracker.unity3d.com/issues/android-video-player-cannot-play-files-located-in-the-persistent-data-directory-on-android-10?_ga=2.2188601.882680562.1607255200-1472655325.1605534586

Recent posts

Discord Chat

Join UnityLibrary Discord chat https://discord.gg/cXT97hU

Recent Comments

  • on Using RenderDoc with Unity
  • on ffmpeg stream raw video into Unity Texture2D
  • on Deploy to Android device with wireless connection
  • on Vector3 maths for dummies!
  • on Waves Shader
  • on Matrix Playground Shader
  • on Vector3 maths for dummies!
  • on Flood Fill Algorithm

@unitycoder_com

OculusMy Tweets

Subscribe to Blog via Email

Tag Cloud

Connect

I managed to set up my first app for the Oculus Quest with Unity’s new Universal Render Pipeline (earlier it was called Lightweight Render Pipeline) in four hours. I write this article, so that for you it may take much less. This article was written in March 2020, it maybe actual until the end of the year, but I am sure the Unity landscape changes too much to be actual after 2021. (Unity version 2019.3.7f1)

I believe Unity 3D first build to Quest could have been done in half an hour. There are obstacles in the way and these make it like a steeplechase. (see pic below) Most likely think the main problem is not the time necessary for the setup, It is the conflict, that you do everything right and it is not running! I started development around 1992 and so I’ve seen a few systems in my life. I know how to put together PC hardware, how to create Android and iOS apps, how to put together VR systems. Still two hours into the process I felt like Robinson Crusoe on a remote desert island. I would say we certainly loose some developers on the way into this, like 20-50% who will say that either they are not enough to develop on VR or the system is just garbage. Anyway let’s go through the issues that arose.

Unity Oculus Development

I was following this links, they show the basic steps to build for Quest:
https://circuitstream.com/blog/oculus-quest-unity-setup/

Quest 1: Oculus assets in two folders

Unity complains about multiple Oculus assemblies in different folders with the same name.

Solution: Delete the non android folder and keep the android folder. (Android is for Quest, non android is for Rift)

Quest 2: ADB.EXE incompatibility

It gave this error: adb server version (41) doesn't match this client (40); killing...

First I tried to change the Project Settings folder to a non unity android SDK, but it didn’t work that way.

Solution: as written here you have to copy adb.exe, adbwinapi.dll, adbwinusbapi.dll from the standard android SDK to the Unity specific version. (First backup, then overwrite.) Why? Why not? This is Unity development, anything can happen.

Quest 3: Build took FOREVER

I have a good intel i7 with 32gbs of RAM, but still each build took like 4-5 minutes (to fail 😉 ).

Solution: Check Development Build, it brings down building time to around one minute.

Quest 4: App starts on the quest and goes into a neverending wait cycle.

This was a nightmare error, because I didn’t know how to handle it. The app started on the device and then it seemed it loads something. I was thinking maybe for the first time it needs one minute to prepare some textures or shaders or whatever.

Solution: Then LarsonMattr gave me a clue: do not use Vulcan, use OpenGL ES 3.0. All right. I googled again how to change that and then it worked.

Quest 5: Rendering runs only on the left eye

The system started, the app started – finally – and then I could only see with my left eye. Right eye render stayed blank.

Oculus Quest 2 Unity Edition

Solution: Project settings: change Stereo Rendering Mode from default Multipass to Multiview.

What can we learn from this?

Finally I made it, it worked, still my usual open questions remains:what can we learn from this?

  • Defaults should be working! (Multiview instead of multipass.)
  • If a rendering system – vulcan – is not advised or working on Quest, it should run to an error and not get stuck forever on the device. EVERYTHING is better than having the Quest on and watching the three dots flashing by without knowing if it will ever change.
  • I think Unity 3D is a general company creating software for multiple devices. So it is the job of the device maker starting with O to create an asset that does a full integration. This integration should include checks that make sure that the software runs well. To be specific a menu item “Oculus Check” with sub-items like “Oculus Quest Check” and “Oculus Rift Check” would be very usefl. These routines then would go and eliminate a bunch of pitfalls along the way.

PS: Oculus Menu

Actually there is an Oculus menu where you can start certain tools and even build. Still it is f**ked up for the moment, if you want to build it builds very slow productive version for 3-4 minutes just to fail in the last second with “Gradle not found”. Tried to fix this error for an hour and then finally decided to use the Unity standard build method. We need to quickly publish a learning solution for Quest and we are stuck with a halfway build soultion. Some strong opinions emerged regarding the bermuda triangle of Unity – Oculus – Android SDK Build Tools.

PS: 2019.3.7f1 Text Mesh Rendering Problem Android

I Unity version 2019.3.7f1 with Universal Rendering Pipeline (Lightweight Rendering Pipeline) the Text Mesh (Textmesh Pro) was rendering totally displaced on a distant plane. This was now fixed with version 2019.3.9f1. Upgrade advised.