Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by joaoborks · Jun 14, 2017 at 05:50 PM · errorvrbug-perhaps

[VR] Properly "Load if available" VR System

Proper "Load if available" VR System

TL;DR: Using Unity's Native VR API [5.6.0f3] returns an error when using OpenVR and no devices are connected.

The Situation

We developers need to test the environment oftenly, and sometimes in a VR environment, not everyone has access to the VR Devices, and may test without it. So far, we were trying to develop a system where we could test with or without a VR Device, by controlling inputs with keyboard and mouse instead.

The Problem

The problem is that if we don't have any VR Devices attached, OpenVR throws an error that cannot be handled.

The Current Setup

Our current setup includes the following logic:

 void Awake()
 {
     StartCoroutine(TryLoadVR());
 }
 
 IEnumerator TryLoadVR()
 {
     // This will return a list with Oculus and OpenVR
     string[] devices = new string[vrDevices.Length];
     for (int i = 0; i < devices.Length; i++)
         devices[i] = vrDevices[i].deviceName;
     // This line if no VR Device is connected returns an error with OpenVR
     VRSettings.LoadDeviceByName(devices);
     yield return null;
     if (string.IsNullOrEmpty(VRSettings.loadedDeviceName))
     {
         // Load Non-VR Input Controls
     }
     else
     {
         // Load VR Input Controls
     }
 }

I have checked Virtual Reality Supported on the Player Settings, and on the list of Virtual Reality Supported SDKs I have on the order:

  1. None

  2. Oculus

  3. OpenVR

The error I'm getting is:

VR: OpenVR Error! OpenVR failed with initialization with error code VRInitError_Init_HmdNotFoundPresenceFailed: "Hmd Not Found Presence Failed (126)"!

I have tried using try catch but it doesn't work to isolate the error, and if it does throw the error, it keeps throwing even after stopping the game application on the editor.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by joaoborks · Jun 14, 2017 at 06:12 PM

Just found out that by adding: VRSettings.LoadDeviceByName("None") if Unity cannot load the VR Device, can keep the game running smoothly after the OpenVR error returned, yet we can't use the Error Pause to track errors, or manually need to enable it each time we play or unpause the game after the startup OpenVR Error which is a little annoying.

Full Code:

 void Awake()
 {
     StartCoroutine(TryLoadVR());
 }
 
 IEnumerator TryLoadVR()
 {
     string[] devices = new string[vrDevices.Length];
     for (int i = 0; i < devices.Length; i++)
         devices[i] = vrDevices[i].deviceName;
     VRSettings.LoadDeviceByName(devices);
     yield return null;
     if (string.IsNullOrEmpty(VRSettings.loadedDeviceName))
     {
         // Load Non-VR Input Controls
         // Stops trying to load something that is not there
         VRSettings.LoadDeviceByName("None");
     }
     else
     {
         // Load VR Input Controls
         VRSettings.enabled = true;
     }
 }

EDIT: Uploaded a public gist to help others with the same difficulties

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SimRuJ · Jan 23, 2019 at 04:05 PM 0
Share

I'm currently working on the same thing (Unity 2017.3) and can't get it to work properly - no matter what order I use for the VR SD$$anonymous$$s (Edit - Project Settings - Player - XR Settings):

  1. OpenVR, then None: If no device is connected, it throws an "HmdNotFound" error (not sure how or if we can catch it). I tried checking if there's an H$$anonymous$$D with if(XRDevice.isPresent) and then loading the according SD$$anonymous$$ (e.g. XRSettings.LoadDeviceByName("None")) in the "Awake" function of the very first script in the very first scene that's loaded but it still throws the same error message.

  2. None, then OpenVR: No error message when no H$$anonymous$$D is connected but if there is, Unity simply doesn't see it (`XRDevice.isPresent` always returns "false") and S$$anonymous$$mVR/OpenVR don't start properly either. So in the end my app runs in non-VR mode, even though there's a device connected.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

143 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Need help, Build Settings not appearing properly Unity 2017 0 Answers

"Exploded" VRChat avatars 1 Answer

VR Package makes Unity crash 1 Answer

Shader works in editor but not in Android - Pass 'meta' has no vertex shader 1 Answer

HDRP visual errors with VR 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges