void OnGUI() { if (overlay == null) { return; } var texture = overlay.texture as RenderTexture; var prevActive = RenderTexture.active; RenderTexture.active = texture; if (Event.current.type == EventType.Repaint) { GL.Clear(false, true, Color.clear); } var area = new Rect(0, 0, texture.width, texture.height); // Account for screen smaller than texture (since mouse position gets clamped) if (Screen.width < texture.width) { area.width = Screen.width; overlay.uvOffset.x = -(float)(texture.width - Screen.width) / (2 * texture.width); } if (Screen.height < texture.height) { area.height = Screen.height; overlay.uvOffset.y = (float)(texture.height - Screen.height) / (2 * texture.height); } GUILayout.BeginArea(area); if (background != null) { GUI.DrawTexture(new Rect( (area.width - background.width) / 2, (area.height - background.height) / 2, background.width, background.height), background); } GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.BeginVertical(); if (logo != null) { GUILayout.Space(area.height / 2 - logoHeight); GUILayout.Box(logo); } GUILayout.Space(menuOffset); bool bHideMenu = GUILayout.Button("[Esc] - Close menu"); GUILayout.BeginHorizontal(); GUILayout.Label(string.Format("Scale: {0:N4}", scale)); { var result = GUILayout.HorizontalSlider(scale, scaleLimits.x, scaleLimits.y); if (result != scale) { SetScale(result); } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(string.Format("Scale limits:")); { var result = GUILayout.TextField(scaleLimitX); if (result != scaleLimitX) { if (float.TryParse(result, out scaleLimits.x)) { scaleLimitX = result; } } } { var result = GUILayout.TextField(scaleLimitY); if (result != scaleLimitY) { if (float.TryParse(result, out scaleLimits.y)) { scaleLimitY = result; } } } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(string.Format("Scale rate:")); { var result = GUILayout.TextField(scaleRateText); if (result != scaleRateText) { if (float.TryParse(result, out scaleRate)) { scaleRateText = result; } } } GUILayout.EndHorizontal(); if (SteamVR.active) { var vr = SteamVR.instance; GUILayout.BeginHorizontal(); { var t = SteamVR_Camera.sceneResolutionScale; int w = (int)(vr.sceneWidth * t); int h = (int)(vr.sceneHeight * t); int pct = (int)(100.0f * t); GUILayout.Label(string.Format("Scene quality: {0}x{1} ({2}%)", w, h, pct)); var result = Mathf.RoundToInt(GUILayout.HorizontalSlider(pct, 50, 200)); if (result != pct) { SteamVR_Camera.sceneResolutionScale = (float)result / 100.0f; } } GUILayout.EndHorizontal(); } overlay.highquality = GUILayout.Toggle(overlay.highquality, "High quality"); if (overlay.highquality) { overlay.curved = GUILayout.Toggle(overlay.curved, "Curved overlay"); overlay.antialias = GUILayout.Toggle(overlay.antialias, "Overlay RGSS(2x2)"); } else { overlay.curved = false; overlay.antialias = false; } var tracker = SteamVR_Render.Top(); if (tracker != null) { tracker.wireframe = GUILayout.Toggle(tracker.wireframe, "Wireframe"); var render = SteamVR_Render.instance; if (render.trackingSpace == ETrackingUniverseOrigin.TrackingUniverseSeated) { if (GUILayout.Button("Switch to Standing")) { render.trackingSpace = ETrackingUniverseOrigin.TrackingUniverseStanding; } if (GUILayout.Button("Center View")) { var system = OpenVR.System; if (system != null) { system.ResetSeatedZeroPose(); } } } else { if (GUILayout.Button("Switch to Seated")) { render.trackingSpace = ETrackingUniverseOrigin.TrackingUniverseSeated; } } } #if !UNITY_EDITOR if (GUILayout.ButtonPrefab("Exit")) { Application.Quit(); } #endif GUILayout.Space(menuOffset); var env = System.Environment.GetEnvironmentVariable("VR_OVERRIDE"); if (env != null) { GUILayout.Label("VR_OVERRIDE=" + env); } GUILayout.Label("Graphics device: " + SystemInfo.graphicsDeviceVersion); GUILayout.EndVertical(); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndArea(); if (cursor != null) { float x = Input.mousePosition.x, y = Screen.height - Input.mousePosition.y; float w = cursor.width, h = cursor.height; GUI.DrawTexture(new Rect(x, y, w, h), cursor); } RenderTexture.active = prevActive; if (bHideMenu) { HideMenu(); } }
public void OnGUI() { var resourcePath = GetResourcePath(); var logo = AssetDatabase.LoadAssetAtPath <Texture2D>(resourcePath + "logo.png"); var rect = GUILayoutUtility.GetRect(position.width, 150, GUI.skin.box); if (logo) { GUI.DrawTexture(rect, logo, ScaleMode.ScaleToFit); } EditorGUILayout.HelpBox("Recommended project settings for SteamVR:", MessageType.Warning); scrollPosition = GUILayout.BeginScrollView(scrollPosition); int numItems = 0; if (!EditorPrefs.HasKey(ignore + buildTarget) && EditorUserBuildSettings.activeBuildTarget != recommended_BuildTarget) { ++numItems; GUILayout.Label(buildTarget + string.Format(currentValue, EditorUserBuildSettings.activeBuildTarget)); GUILayout.BeginHorizontal(); if (GUILayout.Button(string.Format(useRecommended, recommended_BuildTarget))) { #if (UNITY_5_5 || UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0) EditorUserBuildSettings.SwitchActiveBuildTarget(recommended_BuildTarget); #else EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, recommended_BuildTarget); #endif } GUILayout.FlexibleSpace(); if (GUILayout.Button("Ignore")) { EditorPrefs.SetBool(ignore + buildTarget, true); } GUILayout.EndHorizontal(); } #if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0) if (!EditorPrefs.HasKey(ignore + showUnitySplashScreen) && PlayerSettings.showUnitySplashScreen != recommended_ShowUnitySplashScreen) { ++numItems; GUILayout.Label(showUnitySplashScreen + string.Format(currentValue, PlayerSettings.showUnitySplashScreen)); GUILayout.BeginHorizontal(); if (GUILayout.ButtonPrefab(string.Format(useRecommended, recommended_ShowUnitySplashScreen))) { PlayerSettings.showUnitySplashScreen = recommended_ShowUnitySplashScreen; } GUILayout.FlexibleSpace(); if (GUILayout.ButtonPrefab("Ignore")) { EditorPrefs.SetBool(ignore + showUnitySplashScreen, true); } GUILayout.EndHorizontal(); } #else if (!EditorPrefs.HasKey(ignore + showUnitySplashScreen) && PlayerSettings.SplashScreen.show != recommended_ShowUnitySplashScreen) { ++numItems; GUILayout.Label(showUnitySplashScreen + string.Format(currentValue, PlayerSettings.SplashScreen.show)); GUILayout.BeginHorizontal(); if (GUILayout.Button(string.Format(useRecommended, recommended_ShowUnitySplashScreen))) { PlayerSettings.SplashScreen.show = recommended_ShowUnitySplashScreen; } GUILayout.FlexibleSpace(); if (GUILayout.Button("Ignore")) { EditorPrefs.SetBool(ignore + showUnitySplashScreen, true); } GUILayout.EndHorizontal(); } #endif if (!EditorPrefs.HasKey(ignore + defaultIsFullScreen) && PlayerSettings.defaultIsFullScreen != recommended_DefaultIsFullScreen) { ++numItems; GUILayout.Label(defaultIsFullScreen + string.Format(currentValue, PlayerSettings.defaultIsFullScreen)); GUILayout.BeginHorizontal(); if (GUILayout.Button(string.Format(useRecommended, recommended_DefaultIsFullScreen))) { PlayerSettings.defaultIsFullScreen = recommended_DefaultIsFullScreen; } GUILayout.FlexibleSpace(); if (GUILayout.Button("Ignore")) { EditorPrefs.SetBool(ignore + defaultIsFullScreen, true); } GUILayout.EndHorizontal(); } if (!EditorPrefs.HasKey(ignore + defaultScreenSize) && (PlayerSettings.defaultScreenWidth != recommended_DefaultScreenWidth || PlayerSettings.defaultScreenHeight != recommended_DefaultScreenHeight)) { ++numItems; GUILayout.Label(defaultScreenSize + string.Format(" ({0}x{1})", PlayerSettings.defaultScreenWidth, PlayerSettings.defaultScreenHeight)); GUILayout.BeginHorizontal(); if (GUILayout.Button(string.Format("Use recommended ({0}x{1})", recommended_DefaultScreenWidth, recommended_DefaultScreenHeight))) { PlayerSettings.defaultScreenWidth = recommended_DefaultScreenWidth; PlayerSettings.defaultScreenHeight = recommended_DefaultScreenHeight; } GUILayout.FlexibleSpace(); if (GUILayout.Button("Ignore")) { EditorPrefs.SetBool(ignore + defaultScreenSize, true); } GUILayout.EndHorizontal(); } if (!EditorPrefs.HasKey(ignore + runInBackground) && PlayerSettings.runInBackground != recommended_RunInBackground) { ++numItems; GUILayout.Label(runInBackground + string.Format(currentValue, PlayerSettings.runInBackground)); GUILayout.BeginHorizontal(); if (GUILayout.Button(string.Format(useRecommended, recommended_RunInBackground))) { PlayerSettings.runInBackground = recommended_RunInBackground; } GUILayout.FlexibleSpace(); if (GUILayout.Button("Ignore")) { EditorPrefs.SetBool(ignore + runInBackground, true); } GUILayout.EndHorizontal(); } if (!EditorPrefs.HasKey(ignore + displayResolutionDialog) && PlayerSettings.displayResolutionDialog != recommended_DisplayResolutionDialog) { ++numItems; GUILayout.Label(displayResolutionDialog + string.Format(currentValue, PlayerSettings.displayResolutionDialog)); GUILayout.BeginHorizontal(); if (GUILayout.Button(string.Format(useRecommended, recommended_DisplayResolutionDialog))) { PlayerSettings.displayResolutionDialog = recommended_DisplayResolutionDialog; } GUILayout.FlexibleSpace(); if (GUILayout.Button("Ignore")) { EditorPrefs.SetBool(ignore + displayResolutionDialog, true); } GUILayout.EndHorizontal(); } if (!EditorPrefs.HasKey(ignore + resizableWindow) && PlayerSettings.resizableWindow != recommended_ResizableWindow) { ++numItems; GUILayout.Label(resizableWindow + string.Format(currentValue, PlayerSettings.resizableWindow)); GUILayout.BeginHorizontal(); if (GUILayout.Button(string.Format(useRecommended, recommended_ResizableWindow))) { PlayerSettings.resizableWindow = recommended_ResizableWindow; } GUILayout.FlexibleSpace(); if (GUILayout.Button("Ignore")) { EditorPrefs.SetBool(ignore + resizableWindow, true); } GUILayout.EndHorizontal(); } if (!EditorPrefs.HasKey(ignore + fullscreenMode) && PlayerSettings.d3d11FullscreenMode != recommended_FullscreenMode) { ++numItems; GUILayout.Label(fullscreenMode + string.Format(currentValue, PlayerSettings.d3d11FullscreenMode)); GUILayout.BeginHorizontal(); if (GUILayout.Button(string.Format(useRecommended, recommended_FullscreenMode))) { PlayerSettings.d3d11FullscreenMode = recommended_FullscreenMode; } GUILayout.FlexibleSpace(); if (GUILayout.Button("Ignore")) { EditorPrefs.SetBool(ignore + fullscreenMode, true); } GUILayout.EndHorizontal(); } if (!EditorPrefs.HasKey(ignore + visibleInBackground) && PlayerSettings.visibleInBackground != recommended_VisibleInBackground) { ++numItems; GUILayout.Label(visibleInBackground + string.Format(currentValue, PlayerSettings.visibleInBackground)); GUILayout.BeginHorizontal(); if (GUILayout.Button(string.Format(useRecommended, recommended_VisibleInBackground))) { PlayerSettings.visibleInBackground = recommended_VisibleInBackground; } GUILayout.FlexibleSpace(); if (GUILayout.Button("Ignore")) { EditorPrefs.SetBool(ignore + visibleInBackground, true); } GUILayout.EndHorizontal(); } #if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0) if (!EditorPrefs.HasKey(ignore + renderingPath) && PlayerSettings.renderingPath != recommended_RenderPath) { ++numItems; GUILayout.Label(renderingPath + string.Format(currentValue, PlayerSettings.renderingPath)); GUILayout.BeginHorizontal(); if (GUILayout.ButtonPrefab(string.Format(useRecommended, recommended_RenderPath) + " - required for MSAA")) { PlayerSettings.renderingPath = recommended_RenderPath; } GUILayout.FlexibleSpace(); if (GUILayout.ButtonPrefab("Ignore")) { EditorPrefs.SetBool(ignore + renderingPath, true); } GUILayout.EndHorizontal(); } #endif if (!EditorPrefs.HasKey(ignore + colorSpace) && PlayerSettings.colorSpace != recommended_ColorSpace) { ++numItems; GUILayout.Label(colorSpace + string.Format(currentValue, PlayerSettings.colorSpace)); GUILayout.BeginHorizontal(); if (GUILayout.Button(string.Format(useRecommended, recommended_ColorSpace) + " - requires reloading scene")) { PlayerSettings.colorSpace = recommended_ColorSpace; } GUILayout.FlexibleSpace(); if (GUILayout.Button("Ignore")) { EditorPrefs.SetBool(ignore + colorSpace, true); } GUILayout.EndHorizontal(); } if (!EditorPrefs.HasKey(ignore + gpuSkinning) && PlayerSettings.gpuSkinning != recommended_GpuSkinning) { ++numItems; GUILayout.Label(gpuSkinning + string.Format(currentValue, PlayerSettings.gpuSkinning)); GUILayout.BeginHorizontal(); if (GUILayout.Button(string.Format(useRecommended, recommended_GpuSkinning))) { PlayerSettings.gpuSkinning = recommended_GpuSkinning; } GUILayout.FlexibleSpace(); if (GUILayout.Button("Ignore")) { EditorPrefs.SetBool(ignore + gpuSkinning, true); } GUILayout.EndHorizontal(); } #if false if (!EditorPrefs.HasKey(ignore + singlePassStereoRendering) && PlayerSettings.singlePassStereoRendering != recommended_SinglePassStereoRendering) { ++numItems; GUILayout.Label(singlePassStereoRendering + string.Format(currentValue, PlayerSettings.singlePassStereoRendering)); GUILayout.BeginHorizontal(); if (GUILayout.ButtonPrefab(string.Format(useRecommended, recommended_SinglePassStereoRendering))) { PlayerSettings.singlePassStereoRendering = recommended_SinglePassStereoRendering; } GUILayout.FlexibleSpace(); if (GUILayout.ButtonPrefab("Ignore")) { EditorPrefs.SetBool(ignore + singlePassStereoRendering, true); } GUILayout.EndHorizontal(); } #endif GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Clear All Ignores")) { EditorPrefs.DeleteKey(ignore + buildTarget); EditorPrefs.DeleteKey(ignore + showUnitySplashScreen); EditorPrefs.DeleteKey(ignore + defaultIsFullScreen); EditorPrefs.DeleteKey(ignore + defaultScreenSize); EditorPrefs.DeleteKey(ignore + runInBackground); EditorPrefs.DeleteKey(ignore + displayResolutionDialog); EditorPrefs.DeleteKey(ignore + resizableWindow); EditorPrefs.DeleteKey(ignore + fullscreenMode); EditorPrefs.DeleteKey(ignore + visibleInBackground); #if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0) EditorPrefs.DeleteKey(ignore + renderingPath); #endif EditorPrefs.DeleteKey(ignore + colorSpace); EditorPrefs.DeleteKey(ignore + gpuSkinning); #if false EditorPrefs.DeleteKey(ignore + singlePassStereoRendering); #endif } GUILayout.EndHorizontal(); GUILayout.EndScrollView(); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); if (numItems > 0) { if (GUILayout.Button("Accept All")) { // Only set those that have not been explicitly ignored. if (!EditorPrefs.HasKey(ignore + buildTarget)) #if (UNITY_5_5 || UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0) { EditorUserBuildSettings.SwitchActiveBuildTarget(recommended_BuildTarget); } #else { EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, recommended_BuildTarget); } #endif if (!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 (!EditorPrefs.HasKey(ignore + defaultIsFullScreen)) { PlayerSettings.defaultIsFullScreen = recommended_DefaultIsFullScreen; } if (!EditorPrefs.HasKey(ignore + defaultScreenSize)) { PlayerSettings.defaultScreenWidth = recommended_DefaultScreenWidth; PlayerSettings.defaultScreenHeight = recommended_DefaultScreenHeight; } if (!EditorPrefs.HasKey(ignore + runInBackground)) { PlayerSettings.runInBackground = recommended_RunInBackground; } if (!EditorPrefs.HasKey(ignore + displayResolutionDialog)) { PlayerSettings.displayResolutionDialog = recommended_DisplayResolutionDialog; } if (!EditorPrefs.HasKey(ignore + resizableWindow)) { PlayerSettings.resizableWindow = recommended_ResizableWindow; } if (!EditorPrefs.HasKey(ignore + fullscreenMode)) { PlayerSettings.d3d11FullscreenMode = recommended_FullscreenMode; } if (!EditorPrefs.HasKey(ignore + visibleInBackground)) { PlayerSettings.visibleInBackground = recommended_VisibleInBackground; } #if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0) if (!EditorPrefs.HasKey(ignore + renderingPath)) { PlayerSettings.renderingPath = recommended_RenderPath; } #endif if (!EditorPrefs.HasKey(ignore + colorSpace)) { PlayerSettings.colorSpace = recommended_ColorSpace; } if (!EditorPrefs.HasKey(ignore + gpuSkinning)) { PlayerSettings.gpuSkinning = recommended_GpuSkinning; } #if false if (!EditorPrefs.HasKey(ignore + singlePassStereoRendering)) { PlayerSettings.singlePassStereoRendering = recommended_SinglePassStereoRendering; } #endif EditorUtility.DisplayDialog("Accept All", "You made the right choice!", "Ok"); Close(); } if (GUILayout.Button("Ignore All")) { if (EditorUtility.DisplayDialog("Ignore All", "Are you sure?", "Yes, Ignore All", "Cancel")) { // Only ignore those that do not currently match our recommended settings. if (EditorUserBuildSettings.activeBuildTarget != recommended_BuildTarget) { EditorPrefs.SetBool(ignore + buildTarget, true); } #if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0) if (PlayerSettings.showUnitySplashScreen != recommended_ShowUnitySplashScreen) #else if (PlayerSettings.SplashScreen.show != recommended_ShowUnitySplashScreen) #endif { EditorPrefs.SetBool(ignore + showUnitySplashScreen, true); } if (PlayerSettings.defaultIsFullScreen != recommended_DefaultIsFullScreen) { EditorPrefs.SetBool(ignore + defaultIsFullScreen, true); } if (PlayerSettings.defaultScreenWidth != recommended_DefaultScreenWidth || PlayerSettings.defaultScreenHeight != recommended_DefaultScreenHeight) { EditorPrefs.SetBool(ignore + defaultScreenSize, true); } if (PlayerSettings.runInBackground != recommended_RunInBackground) { EditorPrefs.SetBool(ignore + runInBackground, true); } if (PlayerSettings.displayResolutionDialog != recommended_DisplayResolutionDialog) { EditorPrefs.SetBool(ignore + displayResolutionDialog, true); } if (PlayerSettings.resizableWindow != recommended_ResizableWindow) { EditorPrefs.SetBool(ignore + resizableWindow, true); } if (PlayerSettings.d3d11FullscreenMode != recommended_FullscreenMode) { EditorPrefs.SetBool(ignore + fullscreenMode, true); } if (PlayerSettings.visibleInBackground != recommended_VisibleInBackground) { EditorPrefs.SetBool(ignore + visibleInBackground, true); } #if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0) if (PlayerSettings.renderingPath != recommended_RenderPath) { EditorPrefs.SetBool(ignore + renderingPath, true); } #endif if (PlayerSettings.colorSpace != recommended_ColorSpace) { EditorPrefs.SetBool(ignore + colorSpace, true); } if (PlayerSettings.gpuSkinning != recommended_GpuSkinning) { EditorPrefs.SetBool(ignore + gpuSkinning, true); } #if false if (PlayerSettings.singlePassStereoRendering != recommended_SinglePassStereoRendering) { EditorPrefs.SetBool(ignore + singlePassStereoRendering, true); } #endif Close(); } } } else if (GUILayout.Button("Close")) { Close(); } GUILayout.EndHorizontal(); }