Example #1
0
        //--------------------------------------------------------------------------------------------------------------------------
        // Functions

        /// <summary> Returnts the current headset name, according to Unity.XR </summary>
        /// <returns></returns>
        public static string GetCurrentHeadsetName()
        {
            string headset = "";

#if UNITY_2021 || UNITY_2020 || UNITY_2019
            //Needs both XR Plug-in Management and OpenVR for the appropriate Headset name detection.
            UnityEngine.XR.InputDevice hmd = UnityEngine.XR.InputDevices.GetDeviceAtXRNode(UnityEngine.XR.XRNode.Head); //this takes a few seconds to initialize!
            if (hmd != null && hmd.name != null)
            {
                headset = hmd.name;
            }
            else
            {
                Debug.LogError("SG_VR_Setup could not find a headset name. Please ensure that XR Plug-in Management and the appropriate SDK are installed.");
            }
            if (headset.Contains("OpenXR"))
            {
                Debug.LogError("Looks like you're using OpenXR, which does not allow us to detect which headset is used (yet). It's therefore not possible to use this script. :(");
            }
#elif UNITY_2017 || UNITY_2018       //Unity 2017 & Unity 2018
            headset = UnityEngine.XR.XRDevice.model;
            if (headset.Length == 0)
            {
                Debug.LogError("SG_VR_Setup could not find a headset name. Please ensure that 'XR enabled' is set 'true' in Player Settings.");
            }
#endif
            //Debug.Log("Name = \"" + headset + "\"");
            return(headset.ToLower());
        }
        void Start()
        {
            inputDevices = new List <UnityEngine.XR.InputDevice>();
            UnityEngine.XR.InputDevices.GetDevices(inputDevices);


            var leftHandDevices = new List <UnityEngine.XR.InputDevice>();

            leftHandDevice  = UnityEngine.XR.InputDevices.GetDeviceAtXRNode(UnityEngine.XR.XRNode.LeftHand);
            rightHandDevice = UnityEngine.XR.InputDevices.GetDeviceAtXRNode(UnityEngine.XR.XRNode.RightHand);
        }
Example #3
0
        //void OnRenderImage(RenderTexture src, RenderTexture dst)
        //{
        //  if (captureMode == CaptureMode.REGULAR &&
        //    outputTexture && captureSource == CaptureSource.CAMERA)
        //  {
        //    Graphics.Blit(src, dst);
        //    Graphics.Blit(null, outputTexture);
        //    StartCoroutine(BlitRegularTextures());
        //  }
        //}

        void Awake()
        {
            if (singleton != null)
            {
                return;
            }
            singleton    = this;
            instantiated = true;

            captureStarted    = false;
            screenshotStarted = false;

            // Retrieve attached VR devie for sound and microphone capture in VR
            // If expected VR device is not attached, it will capture default audio device
#if UNITY_2019_1_OR_NEWER
            UnityEngine.XR.InputDevice inputDevice = new UnityEngine.XR.InputDevice();
            string vrDeviceName = string.IsNullOrEmpty(inputDevice.name) ? "" : inputDevice.name.ToLower();
#elif UNITY_2017_2_OR_NEWER
            string vrDeviceName = UnityEngine.XR.XRDevice.model.ToLower();
#else
            string vrDeviceName = "";
#endif

            if (vrDeviceName.Contains("rift"))
            {
                attachedHMD = VRDeviceType.OCULUS_RIFT;
            }
            else if (vrDeviceName.Contains("vive"))
            {
                attachedHMD = VRDeviceType.HTC_VIVE;
            }
            else
            {
                attachedHMD = VRDeviceType.UNKNOWN;
            }
        }