private static void CheckAndCopyDefaults()
        {
            if (OpenVRHelpers.IsUsingSteamVRInput())
            {
                return; //don't copy if we're using steamvr input
            }
            OpenVRSettings settings = OpenVRSettings.GetSettings();

            if (settings != null)
            {
                if (settings.HasCopiedDefaults)
                {
                    return; //already copied
                }
            }

            string folderPath = OpenVRSettings.GetStreamingSteamVRPath();

            string[] filesToCopy = GetFiles();

            foreach (string file in filesToCopy)
            {
                FileInfo fileInfo = new FileInfo(file);
                string   newPath  = Path.Combine(folderPath, fileInfo.Name);
                if (File.Exists(newPath) == false)
                {
                    File.Copy(fileInfo.FullName, newPath);
                }
            }

            if (settings != null)
            {
                settings.HasCopiedDefaults = true;
            }
        }
Beispiel #2
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);
        }
Beispiel #3
0
        public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
        {
            FileInfo      buildPath      = new FileInfo(pathToBuiltProject);
            string        buildName      = buildPath.Name.Replace(buildPath.Extension, "");
            DirectoryInfo buildDirectory = buildPath.Directory;

            string dataDirectory = Path.Combine(buildDirectory.FullName, buildName + "_Data");

            if (Directory.Exists(dataDirectory) == false)
            {
                string vsDebugDataDirectory = Path.Combine(buildDirectory.FullName, "build/bin/" + buildName + "_Data");
                if (Directory.Exists(vsDebugDataDirectory) == false)
                {
                    Debug.LogError("<b>[OpenVR]</b> Could not find (vs debug) data directory at: " + dataDirectory);
                    Debug.LogError("<b>[OpenVR]</b> Could not find data directory at: " + dataDirectory);
                }
                else
                {
                    dataDirectory = vsDebugDataDirectory;
                }
            }

            string streamingAssets = Path.Combine(dataDirectory, "StreamingAssets");

            if (Directory.Exists(streamingAssets) == false)
            {
                Directory.CreateDirectory(streamingAssets);
            }

            string streamingSteamVR = Path.Combine(streamingAssets, "SteamVR");

            if (Directory.Exists(streamingSteamVR) == false)
            {
                Directory.CreateDirectory(streamingSteamVR);
            }


            OpenVRSettings settings            = OpenVRSettings.GetSettings();
            FileInfo       currentSettingsPath = new FileInfo(AssetDatabase.GetAssetPath(settings));
            FileInfo       newSettingsPath     = new FileInfo(Path.Combine(streamingSteamVR, "OpenVRSettings.asset"));

            if (newSettingsPath.Exists)
            {
                newSettingsPath.IsReadOnly = false;
                newSettingsPath.Delete();
            }

            File.Copy(currentSettingsPath.FullName, newSettingsPath.FullName);

            Debug.Log("Copied openvr settings to build directory: " + newSettingsPath.FullName);
        }
Beispiel #4
0
        private static void PrintOpenVRSettings()
        {
            OpenVRSettings settings = OpenVRSettings.GetSettings(false);

            if (settings == null)
            {
                LogWarning("OpenVRSettings are null.");
                return;
            }
            LogDebug("OpenVR Settings:");
            LogDebug("  StereoRenderingMode: " + settings.StereoRenderingMode);
            LogDebug("  InitializationType: " + settings.InitializationType);
            LogDebug("  ActionManifestFileRelativeFilePath: " + settings.ActionManifestFileRelativeFilePath);
            LogDebug("  MirrorView: " + settings.MirrorView);
        }
Beispiel #5
0
        public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
        {
            if (target != BuildTarget.StandaloneLinux64 && target != BuildTarget.StandaloneWindows)
            {
                return;
            }

            OpenVRSettings settings  = OpenVRSettings.GetSettings();
            bool           needsSave = false;

            if (OpenVRHelpers.IsUsingSteamVRInput())
            {
                bool wasLegacy = settings.IsLegacy;
                settings.IsLegacy = false;

                if (settings.IsLegacy != wasLegacy)
                {
                    needsSave = true;
                }
            }

            bool saved = settings.InitializeActionManifestFileRelativeFilePath();

            string settingsAssetPath = AssetDatabase.GetAssetPath(settings);

            if (string.IsNullOrEmpty(settingsAssetPath))
            {
                CreatePath(defaultAssetPath);
                UnityEditor.AssetDatabase.CreateAsset(settings, defaultAssetPath);
                settingsAssetPath = AssetDatabase.GetAssetPath(settings);
            }
            else if (needsSave)
            {
                UnityEditor.EditorUtility.SetDirty(settings);
                UnityEditor.AssetDatabase.SaveAssets();
            }


            FileInfo      buildPath      = new FileInfo(pathToBuiltProject);
            string        buildName      = buildPath.Name.Replace(buildPath.Extension, "");
            DirectoryInfo buildDirectory = buildPath.Directory;

            string dataDirectory = Path.Combine(buildDirectory.FullName, buildName + "_Data");

            if (Directory.Exists(dataDirectory) == false)
            {
                string vsDebugDataDirectory = Path.Combine(buildDirectory.FullName, "build/bin/" + buildName + "_Data");
                if (Directory.Exists(vsDebugDataDirectory) == false)
                {
                    Debug.LogError("<b>[OpenVR]</b> Could not find data directory at: " + dataDirectory + ". Also checked vs debug at: " + vsDebugDataDirectory);
                }
                else
                {
                    dataDirectory = vsDebugDataDirectory;
                }
            }

            string streamingAssets = Path.Combine(dataDirectory, "StreamingAssets");

            if (Directory.Exists(streamingAssets) == false)
            {
                Directory.CreateDirectory(streamingAssets);
            }

            string streamingSteamVR = Path.Combine(streamingAssets, "SteamVR");

            if (Directory.Exists(streamingSteamVR) == false)
            {
                Directory.CreateDirectory(streamingSteamVR);
            }

            Debug.Log("settingsAssetPath: " + settingsAssetPath);

            FileInfo currentSettingsPath = new FileInfo(settingsAssetPath);
            FileInfo newSettingsPath     = new FileInfo(Path.Combine(streamingSteamVR, "OpenVRSettings.asset"));

            if (newSettingsPath.Exists)
            {
                newSettingsPath.IsReadOnly = false;
                newSettingsPath.Delete();
            }

            File.Copy(currentSettingsPath.FullName, newSettingsPath.FullName);

            Debug.Log("Copied openvr settings to build directory: " + newSettingsPath.FullName);
        }
Beispiel #6
0
        public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
        {
            //make sure we're on a reasonable target
            if (target != BuildTarget.StandaloneLinux64 && target != BuildTarget.StandaloneWindows && target != BuildTarget.StandaloneWindows64)
            {
                return;
            }

#if UNITY_XR_MANAGEMENT
            //make sure we have the xr settings
            XRGeneralSettings generalSettings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget));
            if (generalSettings == null)
            {
                return;
            }

            //make sure our loader is checked
            bool hasLoader = generalSettings.Manager.loaders.Any(loader => loader is OpenVRLoader);
            if (hasLoader == false)
            {
                return;
            }
#endif

            OpenVRSettings settings = OpenVRSettings.GetSettings();

            bool saved = settings.InitializeActionManifestFileRelativeFilePath();

            string settingsAssetPath = AssetDatabase.GetAssetPath(settings);
            if (string.IsNullOrEmpty(settingsAssetPath))
            {
                CreatePath(defaultAssetPath);
                UnityEditor.AssetDatabase.CreateAsset(settings, defaultAssetPath);
                settingsAssetPath = AssetDatabase.GetAssetPath(settings);
            }


            FileInfo      buildPath      = new FileInfo(pathToBuiltProject);
            string        buildName      = buildPath.Name.Replace(buildPath.Extension, "");
            DirectoryInfo buildDirectory = buildPath.Directory;

            string dataDirectory = Path.Combine(buildDirectory.FullName, buildName + "_Data");
            if (Directory.Exists(dataDirectory) == false)
            {
                string vsDebugDataDirectory = Path.Combine(buildDirectory.FullName, "build/bin/" + buildName + "_Data");
                if (Directory.Exists(vsDebugDataDirectory) == false)
                {
                    Debug.LogError("<b>[OpenVR]</b> Could not find data directory at: " + dataDirectory + ". Also checked vs debug at: " + vsDebugDataDirectory);
                }
                else
                {
                    dataDirectory = vsDebugDataDirectory;
                }
            }

            string streamingAssets = Path.Combine(dataDirectory, "StreamingAssets");
            if (Directory.Exists(streamingAssets) == false)
            {
                Directory.CreateDirectory(streamingAssets);
            }

            string streamingSteamVR = Path.Combine(streamingAssets, "SteamVR");
            if (Directory.Exists(streamingSteamVR) == false)
            {
                Directory.CreateDirectory(streamingSteamVR);
            }

            Debug.Log("settingsAssetPath: " + settingsAssetPath);

            FileInfo currentSettingsPath = new FileInfo(settingsAssetPath);
            FileInfo newSettingsPath     = new FileInfo(Path.Combine(streamingSteamVR, "OpenVRSettings.asset"));

            if (newSettingsPath.Exists)
            {
                newSettingsPath.IsReadOnly = false;
                newSettingsPath.Delete();
            }

            File.Copy(currentSettingsPath.FullName, newSettingsPath.FullName);

            Debug.Log("Copied openvr settings to build directory: " + newSettingsPath.FullName);
        }