static void Update()
        {
            bool show =
                (!EditorPrefs.HasKey(ignore + buildTarget) &&
                 EditorUserBuildSettings.activeBuildTarget != recommended_BuildTarget) ||
                (!EditorPrefs.HasKey(ignore + showUnitySplashScreen) &&
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
                 PlayerSettings.showUnitySplashScreen != recommended_ShowUnitySplashScreen) ||
#else
                 PlayerSettings.SplashScreen.show != recommended_ShowUnitySplashScreen) ||
#endif
#if UNITY_2018_1_OR_NEWER
                (!EditorPrefs.HasKey(ignore + defaultIsFullScreen) &&
                 PlayerSettings.fullScreenMode != recommended_FullScreenMode) ||
#else
                (!EditorPrefs.HasKey(ignore + defaultIsFullScreen) &&
                 PlayerSettings.defaultIsFullScreen != recommended_DefaultIsFullScreen) ||
                (!EditorPrefs.HasKey(ignore + fullscreenMode) &&
                 PlayerSettings.d3d11FullscreenMode != recommended_FullscreenMode) ||
#endif
                (!EditorPrefs.HasKey(ignore + defaultScreenSize) &&
                 (PlayerSettings.defaultScreenWidth != recommended_DefaultScreenWidth ||
                  PlayerSettings.defaultScreenHeight != recommended_DefaultScreenHeight)) ||
                (!EditorPrefs.HasKey(ignore + runInBackground) &&
                 PlayerSettings.runInBackground != recommended_RunInBackground) ||
                (!EditorPrefs.HasKey(ignore + displayResolutionDialog) &&
                 PlayerSettings.displayResolutionDialog != recommended_DisplayResolutionDialog) ||
                (!EditorPrefs.HasKey(ignore + resizableWindow) &&
                 PlayerSettings.resizableWindow != recommended_ResizableWindow) ||
                (!EditorPrefs.HasKey(ignore + visibleInBackground) &&
                 PlayerSettings.visibleInBackground != recommended_VisibleInBackground) ||
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
                (!EditorPrefs.HasKey(ignore + renderingPath) &&
                 PlayerSettings.renderingPath != recommended_RenderPath) ||
#endif
                (!EditorPrefs.HasKey(ignore + colorSpace) &&
                 PlayerSettings.colorSpace != recommended_ColorSpace) ||
                (!EditorPrefs.HasKey(ignore + gpuSkinning) &&
                 PlayerSettings.gpuSkinning != recommended_GpuSkinning) ||
#if false
                (!EditorPrefs.HasKey(ignore + singlePassStereoRendering) &&
                 PlayerSettings.singlePassStereoRendering != recommended_SinglePassStereoRendering) ||
#endif
                forceShow;

            if (show)
            {
                window         = GetWindow <SteamVR_UnitySettingsWindow>(true);
                window.minSize = new Vector2(320, 440);
                //window.title = "SteamVR";
            }

            string[] dlls = new string[]
            {
                "Plugins/x86/openvr_api.dll",
                "Plugins/x86_64/openvr_api.dll"
            };

            foreach (string path in dlls)
            {
                if (!File.Exists(Application.dataPath + "/" + path))
                {
                    continue;
                }

                if (AssetDatabase.DeleteAsset("Assets/" + path))
                {
                    Debug.Log("<b>[SteamVR Setup]</b> Deleting " + path);
                }
                else
                {
                    Debug.Log("<b>[SteamVR Setup]</b> " + path +
                              " in use; cannot delete.  Please restart Unity to complete upgrade.");
                }
            }

            EditorApplication.update -= Update;
        }
Ejemplo n.º 2
0
        static void Update()
        {
            bool show =
                (!EditorPrefs.HasKey(ignore + buildTarget) &&
                 EditorUserBuildSettings.activeBuildTarget != recommended_BuildTarget) ||
                (!EditorPrefs.HasKey(ignore + showUnitySplashScreen) &&
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
                 PlayerSettings.showUnitySplashScreen != recommended_ShowUnitySplashScreen) ||
#else
                 PlayerSettings.SplashScreen.show != recommended_ShowUnitySplashScreen) ||
#endif

#if UNITY_2018_1_OR_NEWER
                (!EditorPrefs.HasKey(ignore + defaultIsFullScreen) &&
                 PlayerSettings.fullScreenMode != recommended_FullScreenMode) ||
#else
                (!EditorPrefs.HasKey(ignore + defaultIsFullScreen) &&
                 PlayerSettings.defaultIsFullScreen != recommended_DefaultIsFullScreen) ||
                (!EditorPrefs.HasKey(ignore + fullscreenMode) &&
                 PlayerSettings.d3d11FullscreenMode != recommended_FullscreenMode) ||
#endif
                (!EditorPrefs.HasKey(ignore + defaultScreenSize) &&
                 (PlayerSettings.defaultScreenWidth != recommended_DefaultScreenWidth ||
                  PlayerSettings.defaultScreenHeight != recommended_DefaultScreenHeight)) ||
                (!EditorPrefs.HasKey(ignore + runInBackground) &&
                 PlayerSettings.runInBackground != recommended_RunInBackground) ||
                (!EditorPrefs.HasKey(ignore + displayResolutionDialog) &&
                 PlayerSettings.displayResolutionDialog != recommended_DisplayResolutionDialog) ||
                (!EditorPrefs.HasKey(ignore + resizableWindow) &&
                 PlayerSettings.resizableWindow != recommended_ResizableWindow) ||
                (!EditorPrefs.HasKey(ignore + visibleInBackground) &&
                 PlayerSettings.visibleInBackground != recommended_VisibleInBackground) ||
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
                (!EditorPrefs.HasKey(ignore + renderingPath) &&
                 PlayerSettings.renderingPath != recommended_RenderPath) ||
#endif
                (!EditorPrefs.HasKey(ignore + colorSpace) &&
                 PlayerSettings.colorSpace != recommended_ColorSpace) ||
                (!EditorPrefs.HasKey(ignore + gpuSkinning) &&
                 PlayerSettings.gpuSkinning != recommended_GpuSkinning) ||
#if false
                (!EditorPrefs.HasKey(ignore + singlePassStereoRendering) &&
                 PlayerSettings.singlePassStereoRendering != recommended_SinglePassStereoRendering) ||
#endif
                forceShow;

            if (show)
            {
                window         = GetWindow <SteamVR_UnitySettingsWindow>(true);
                window.minSize = new Vector2(320, 440);
                //window.title = "SteamVR";
            }

            if (SteamVR_Preferences.AutoEnableVR)
            {
                // Switch to native OpenVR support.
                var updated = false;

                if (!PlayerSettings.virtualRealitySupported)
                {
                    PlayerSettings.virtualRealitySupported = true;
                    updated = true;
                }

#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
                var devices = UnityEditorInternal.VR.VREditor.GetVREnabledDevices(BuildTargetGroup.Standalone);
#else
                var devices = UnityEditorInternal.VR.VREditor.GetVREnabledDevicesOnTargetGroup(BuildTargetGroup.Standalone);
#endif
                var hasOpenVR = false;
                foreach (var device in devices)
                {
                    if (device.ToLower() == "openvr")
                    {
                        hasOpenVR = true;
                    }
                }


                if (!hasOpenVR)
                {
                    string[] newDevices;
                    if (updated)
                    {
                        newDevices = new string[] { "OpenVR" };
                    }
                    else
                    {
                        newDevices = new string[devices.Length + 1];
                        for (int i = 0; i < devices.Length; i++)
                        {
                            newDevices[i] = devices[i];
                        }
                        newDevices[devices.Length] = "OpenVR";
                        updated = true;
                    }
#if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
                    UnityEditorInternal.VR.VREditor.SetVREnabledDevices(BuildTargetGroup.Standalone, newDevices);
#else
                    UnityEditorInternal.VR.VREditor.SetVREnabledDevicesOnTargetGroup(BuildTargetGroup.Standalone, newDevices);
#endif
                }

                if (updated)
                {
                    Debug.Log("Switching to native OpenVR support.");
                }
            }

            var dlls = new string[]
            {
                "Plugins/x86/openvr_api.dll",
                "Plugins/x86_64/openvr_api.dll"
            };

            foreach (var path in dlls)
            {
                if (!File.Exists(Application.dataPath + "/" + path))
                {
                    continue;
                }

                if (AssetDatabase.DeleteAsset("Assets/" + path))
                {
                    Debug.Log("Deleting " + path);
                }
                else
                {
                    Debug.Log(path + " in use; cannot delete.  Please restart Unity to complete upgrade.");
                }
            }

            EditorApplication.update -= Update;
        }