Search Unity

Stock Unity VR: Oculus detection

Discussion in 'AR/VR (XR) Discussion' started by plmx, Jan 29, 2017.

  1. plmx

    plmx

    Joined:
    Sep 10, 2015
    Posts:
    308
    Still trying to support both Vive and Rift with plain Unity. Now, the Oculus Touch buttons map differently to the Joystick names (as shown here: https://docs.unity3d.com/Manual/OpenVRControllers.html). Some button IDs (e.g. 0) map to different buttons, e.g. Menu on the Vive and One ("A") on the Rift. This means I have to KNOW if a Rift or a Vive is installed so I can map the keys to the correct in-game actions.

    However, I can't seem to figure out how to get that info when running OpenVR. If I run with the Oculus runtime only (no OpenVR), I get "Oculus" as a result from VRSettings.loadedDeviceName, and "Touch" from "UnityEngine.Input.GetJoystickNames()". However, that is not the case when running SteamVR, which also supports the Rift. I always get "OpenVR" back, no matter if the Rift or the Vive is installed.

    What is the suggested way of getting this information?
     
    Last edited: Jan 29, 2017
    bzor likes this.
  2. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    305
    This is a common problem and one which Im looking for an official answer from Unity. For the time being I use:

    Code (CSharp):
    1. if (VRDevice.model.ToLower().Contains("oculus")) {
     
    plmx likes this.
  3. plmx

    plmx

    Joined:
    Sep 10, 2015
    Posts:
    308
    I must have missed that particular string. Thanks!