Example #1
0
        private static bool InitializeXRSDKLoaders(XRManagerSettings managerSettings)
        {
            LogDebug("Initializing XRSDK Loaders...");
            if (managerSettings == null)
            {
                LogError("XRManagerSettings instance is null, cannot initialize loader.");
                return(false);
            }
            managerSettings.InitializeLoaderSync();
            if (managerSettings.activeLoader == null)
            {
                LogError("XRManager.activeLoader is null! Cannot initialize VR!");
                return(false);
            }
            OpenVRSettings openVrSettings = OpenVRSettings.GetSettings(false);

            if (openVrSettings != null)
            {
                OpenVRSettings.MirrorViewModes mirrorMode = VVRConfig.GetMirrorViewMode();
                LogInfo("Mirror View Mode: " + mirrorMode);
                openVrSettings.SetMirrorViewMode(mirrorMode);
            }
            LogDebug("Got non-null Active Loader.");
            return(true);
        }
Example #2
0
        /// This allows end users to switch mirror view modes at runtime with a file.
        /// To use place a file called openvr_mirrorview.cfg in the same directory as the executable (or root of project).
        /// The file should be one line with the following key/value:
        /// MirrorViewMode=openvr
        /// Acceptable values are left, right, none, and openvr. OpenVR mode is in beta but will show overlays and chaperone bounds.
        private void ReadMirrorModeConfig()
        {
            try
            {
                var lines = System.IO.File.ReadAllLines(mirrorViewPath);
                foreach (var line in lines)
                {
                    var split = line.Split('=');
                    if (split.Length == 2)
                    {
                        var key = split[0];
                        if (key == "MirrorViewMode")
                        {
                            string stringMode = split[1];
                            OpenVRSettings.MirrorViewModes mode = OpenVRSettings.MirrorViewModes.None;
                            if (stringMode.Equals("left", System.StringComparison.CurrentCultureIgnoreCase))
                            {
                                mode = OpenVRSettings.MirrorViewModes.Left;
                            }
                            else if (stringMode.Equals("right", System.StringComparison.CurrentCultureIgnoreCase))
                            {
                                mode = OpenVRSettings.MirrorViewModes.Right;
                            }
                            else if (stringMode.Equals("openvr", System.StringComparison.CurrentCultureIgnoreCase))
                            {
                                mode = OpenVRSettings.MirrorViewModes.OpenVR;
                            }
                            else if (stringMode.Equals("none", System.StringComparison.CurrentCultureIgnoreCase))
                            {
                                mode = OpenVRSettings.MirrorViewModes.None;
                            }
                            else
                            {
                                Debug.LogError("<b>[OpenVR]</b> Invalid mode specified in openvr_mirrorview.cfg. Options are: Left, Right, None, and OpenVR.");
                            }

                            Debug.Log("<b>[OpenVR]</b> Mirror View Mode changed via file to: " + mode.ToString());
                            OpenVRSettings.SetMirrorViewMode((ushort)mode); //bypass the local set.
                        }
                    }
                }
            }
            catch
            { }
        }