The Swartz-Manning’s first exhibit will provide a detailed history of Aaron Swartz Day. https://www.aaronswartzday.org/vr
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SteamVR_Settings.cs 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. //======= Copyright (c) Valve Corporation, All rights reserved. ===============
  2. //
  3. // Purpose: Prompt developers to use settings most compatible with SteamVR.
  4. //
  5. //=============================================================================
  6. using UnityEngine;
  7. using UnityEditor;
  8. using System.IO;
  9. [InitializeOnLoad]
  10. public class SteamVR_Settings : EditorWindow
  11. {
  12. const bool forceShow = false; // Set to true to get the dialog to show back up in the case you clicked Ignore All.
  13. const string ignore = "ignore.";
  14. const string useRecommended = "Use recommended ({0})";
  15. const string currentValue = " (current = {0})";
  16. const string buildTarget = "Build Target";
  17. const string showUnitySplashScreen = "Show Unity Splashscreen";
  18. const string defaultIsFullScreen = "Default is Fullscreen";
  19. const string defaultScreenSize = "Default Screen Size";
  20. const string runInBackground = "Run In Background";
  21. const string displayResolutionDialog = "Display Resolution Dialog";
  22. const string resizableWindow = "Resizable Window";
  23. const string fullscreenMode = "D3D11 Fullscreen Mode";
  24. const string visibleInBackground = "Visible In Background";
  25. #if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
  26. const string renderingPath = "Rendering Path";
  27. #endif
  28. const string colorSpace = "Color Space";
  29. const string gpuSkinning = "GPU Skinning";
  30. #if false // skyboxes are currently broken
  31. const string singlePassStereoRendering = "Single-Pass Stereo Rendering";
  32. #endif
  33. const BuildTarget recommended_BuildTarget = BuildTarget.StandaloneWindows64;
  34. const bool recommended_ShowUnitySplashScreen = false;
  35. const bool recommended_DefaultIsFullScreen = false;
  36. const int recommended_DefaultScreenWidth = 1024;
  37. const int recommended_DefaultScreenHeight = 768;
  38. const bool recommended_RunInBackground = true;
  39. const ResolutionDialogSetting recommended_DisplayResolutionDialog = ResolutionDialogSetting.HiddenByDefault;
  40. const bool recommended_ResizableWindow = true;
  41. const D3D11FullscreenMode recommended_FullscreenMode = D3D11FullscreenMode.FullscreenWindow;
  42. const bool recommended_VisibleInBackground = true;
  43. #if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
  44. const RenderingPath recommended_RenderPath = RenderingPath.Forward;
  45. #endif
  46. const ColorSpace recommended_ColorSpace = ColorSpace.Linear;
  47. const bool recommended_GpuSkinning = true;
  48. #if false
  49. const bool recommended_SinglePassStereoRendering = true;
  50. #endif
  51. static SteamVR_Settings window;
  52. static SteamVR_Settings()
  53. {
  54. EditorApplication.update += Update;
  55. }
  56. static void Update()
  57. {
  58. bool show =
  59. (!EditorPrefs.HasKey(ignore + buildTarget) &&
  60. EditorUserBuildSettings.activeBuildTarget != recommended_BuildTarget) ||
  61. (!EditorPrefs.HasKey(ignore + showUnitySplashScreen) &&
  62. #if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
  63. PlayerSettings.showUnitySplashScreen != recommended_ShowUnitySplashScreen) ||
  64. #else
  65. PlayerSettings.SplashScreen.show != recommended_ShowUnitySplashScreen) ||
  66. #endif
  67. (!EditorPrefs.HasKey(ignore + defaultIsFullScreen) &&
  68. PlayerSettings.defaultIsFullScreen != recommended_DefaultIsFullScreen) ||
  69. (!EditorPrefs.HasKey(ignore + defaultScreenSize) &&
  70. (PlayerSettings.defaultScreenWidth != recommended_DefaultScreenWidth ||
  71. PlayerSettings.defaultScreenHeight != recommended_DefaultScreenHeight)) ||
  72. (!EditorPrefs.HasKey(ignore + runInBackground) &&
  73. PlayerSettings.runInBackground != recommended_RunInBackground) ||
  74. (!EditorPrefs.HasKey(ignore + displayResolutionDialog) &&
  75. PlayerSettings.displayResolutionDialog != recommended_DisplayResolutionDialog) ||
  76. (!EditorPrefs.HasKey(ignore + resizableWindow) &&
  77. PlayerSettings.resizableWindow != recommended_ResizableWindow) ||
  78. (!EditorPrefs.HasKey(ignore + fullscreenMode) &&
  79. PlayerSettings.d3d11FullscreenMode != recommended_FullscreenMode) ||
  80. (!EditorPrefs.HasKey(ignore + visibleInBackground) &&
  81. PlayerSettings.visibleInBackground != recommended_VisibleInBackground) ||
  82. #if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
  83. (!EditorPrefs.HasKey(ignore + renderingPath) &&
  84. PlayerSettings.renderingPath != recommended_RenderPath) ||
  85. #endif
  86. (!EditorPrefs.HasKey(ignore + colorSpace) &&
  87. PlayerSettings.colorSpace != recommended_ColorSpace) ||
  88. (!EditorPrefs.HasKey(ignore + gpuSkinning) &&
  89. PlayerSettings.gpuSkinning != recommended_GpuSkinning) ||
  90. #if false
  91. (!EditorPrefs.HasKey(ignore + singlePassStereoRendering) &&
  92. PlayerSettings.singlePassStereoRendering != recommended_SinglePassStereoRendering) ||
  93. #endif
  94. forceShow;
  95. if (show)
  96. {
  97. window = GetWindow<SteamVR_Settings>(true);
  98. window.minSize = new Vector2(320, 440);
  99. //window.title = "SteamVR";
  100. }
  101. if (SteamVR_Preferences.AutoEnableVR)
  102. {
  103. // Switch to native OpenVR support.
  104. var updated = false;
  105. if (!PlayerSettings.virtualRealitySupported)
  106. {
  107. PlayerSettings.virtualRealitySupported = true;
  108. updated = true;
  109. }
  110. #if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
  111. var devices = UnityEditorInternal.VR.VREditor.GetVREnabledDevices(BuildTargetGroup.Standalone);
  112. #else
  113. var devices = UnityEditorInternal.VR.VREditor.GetVREnabledDevicesOnTargetGroup(BuildTargetGroup.Standalone);
  114. #endif
  115. var hasOpenVR = false;
  116. foreach (var device in devices)
  117. if (device.ToLower() == "openvr")
  118. hasOpenVR = true;
  119. if (!hasOpenVR)
  120. {
  121. string[] newDevices;
  122. if (updated)
  123. {
  124. newDevices = new string[] { "OpenVR" };
  125. }
  126. else
  127. {
  128. newDevices = new string[devices.Length + 1];
  129. for (int i = 0; i < devices.Length; i++)
  130. newDevices[i] = devices[i];
  131. newDevices[devices.Length] = "OpenVR";
  132. updated = true;
  133. }
  134. #if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
  135. UnityEditorInternal.VR.VREditor.SetVREnabledDevices(BuildTargetGroup.Standalone, newDevices);
  136. #else
  137. UnityEditorInternal.VR.VREditor.SetVREnabledDevicesOnTargetGroup(BuildTargetGroup.Standalone, newDevices);
  138. #endif
  139. }
  140. if (updated)
  141. Debug.Log("Switching to native OpenVR support.");
  142. }
  143. var dlls = new string[]
  144. {
  145. "Plugins/x86/openvr_api.dll",
  146. "Plugins/x86_64/openvr_api.dll"
  147. };
  148. foreach (var path in dlls)
  149. {
  150. if (!File.Exists(Application.dataPath + "/" + path))
  151. continue;
  152. if (AssetDatabase.DeleteAsset("Assets/" + path))
  153. Debug.Log("Deleting " + path);
  154. else
  155. {
  156. Debug.Log(path + " in use; cannot delete. Please restart Unity to complete upgrade.");
  157. }
  158. }
  159. EditorApplication.update -= Update;
  160. }
  161. Vector2 scrollPosition;
  162. string GetResourcePath()
  163. {
  164. var ms = MonoScript.FromScriptableObject(this);
  165. var path = AssetDatabase.GetAssetPath(ms);
  166. path = Path.GetDirectoryName(path);
  167. return path.Substring(0, path.Length - "Editor".Length) + "Textures/";
  168. }
  169. public void OnGUI()
  170. {
  171. var resourcePath = GetResourcePath();
  172. var logo = AssetDatabase.LoadAssetAtPath<Texture2D>(resourcePath + "logo.png");
  173. var rect = GUILayoutUtility.GetRect(position.width, 150, GUI.skin.box);
  174. if (logo)
  175. GUI.DrawTexture(rect, logo, ScaleMode.ScaleToFit);
  176. EditorGUILayout.HelpBox("Recommended project settings for SteamVR:", MessageType.Warning);
  177. scrollPosition = GUILayout.BeginScrollView(scrollPosition);
  178. int numItems = 0;
  179. if (!EditorPrefs.HasKey(ignore + buildTarget) &&
  180. EditorUserBuildSettings.activeBuildTarget != recommended_BuildTarget)
  181. {
  182. ++numItems;
  183. GUILayout.Label(buildTarget + string.Format(currentValue, EditorUserBuildSettings.activeBuildTarget));
  184. GUILayout.BeginHorizontal();
  185. if (GUILayout.Button(string.Format(useRecommended, recommended_BuildTarget)))
  186. {
  187. #if (UNITY_5_5 || UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
  188. EditorUserBuildSettings.SwitchActiveBuildTarget(recommended_BuildTarget);
  189. #else
  190. EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, recommended_BuildTarget);
  191. #endif
  192. }
  193. GUILayout.FlexibleSpace();
  194. if (GUILayout.Button("Ignore"))
  195. {
  196. EditorPrefs.SetBool(ignore + buildTarget, true);
  197. }
  198. GUILayout.EndHorizontal();
  199. }
  200. #if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
  201. if (!EditorPrefs.HasKey(ignore + showUnitySplashScreen) &&
  202. PlayerSettings.showUnitySplashScreen != recommended_ShowUnitySplashScreen)
  203. {
  204. ++numItems;
  205. GUILayout.Label(showUnitySplashScreen + string.Format(currentValue, PlayerSettings.showUnitySplashScreen));
  206. GUILayout.BeginHorizontal();
  207. if (GUILayout.Button(string.Format(useRecommended, recommended_ShowUnitySplashScreen)))
  208. {
  209. PlayerSettings.showUnitySplashScreen = recommended_ShowUnitySplashScreen;
  210. }
  211. GUILayout.FlexibleSpace();
  212. if (GUILayout.Button("Ignore"))
  213. {
  214. EditorPrefs.SetBool(ignore + showUnitySplashScreen, true);
  215. }
  216. GUILayout.EndHorizontal();
  217. }
  218. #else
  219. if (!EditorPrefs.HasKey(ignore + showUnitySplashScreen) &&
  220. PlayerSettings.SplashScreen.show != recommended_ShowUnitySplashScreen)
  221. {
  222. ++numItems;
  223. GUILayout.Label(showUnitySplashScreen + string.Format(currentValue, PlayerSettings.SplashScreen.show));
  224. GUILayout.BeginHorizontal();
  225. if (GUILayout.Button(string.Format(useRecommended, recommended_ShowUnitySplashScreen)))
  226. {
  227. PlayerSettings.SplashScreen.show = recommended_ShowUnitySplashScreen;
  228. }
  229. GUILayout.FlexibleSpace();
  230. if (GUILayout.Button("Ignore"))
  231. {
  232. EditorPrefs.SetBool(ignore + showUnitySplashScreen, true);
  233. }
  234. GUILayout.EndHorizontal();
  235. }
  236. #endif
  237. if (!EditorPrefs.HasKey(ignore + defaultIsFullScreen) &&
  238. PlayerSettings.defaultIsFullScreen != recommended_DefaultIsFullScreen)
  239. {
  240. ++numItems;
  241. GUILayout.Label(defaultIsFullScreen + string.Format(currentValue, PlayerSettings.defaultIsFullScreen));
  242. GUILayout.BeginHorizontal();
  243. if (GUILayout.Button(string.Format(useRecommended, recommended_DefaultIsFullScreen)))
  244. {
  245. PlayerSettings.defaultIsFullScreen = recommended_DefaultIsFullScreen;
  246. }
  247. GUILayout.FlexibleSpace();
  248. if (GUILayout.Button("Ignore"))
  249. {
  250. EditorPrefs.SetBool(ignore + defaultIsFullScreen, true);
  251. }
  252. GUILayout.EndHorizontal();
  253. }
  254. if (!EditorPrefs.HasKey(ignore + defaultScreenSize) &&
  255. (PlayerSettings.defaultScreenWidth != recommended_DefaultScreenWidth ||
  256. PlayerSettings.defaultScreenHeight != recommended_DefaultScreenHeight))
  257. {
  258. ++numItems;
  259. GUILayout.Label(defaultScreenSize + string.Format(" ({0}x{1})", PlayerSettings.defaultScreenWidth, PlayerSettings.defaultScreenHeight));
  260. GUILayout.BeginHorizontal();
  261. if (GUILayout.Button(string.Format("Use recommended ({0}x{1})", recommended_DefaultScreenWidth, recommended_DefaultScreenHeight)))
  262. {
  263. PlayerSettings.defaultScreenWidth = recommended_DefaultScreenWidth;
  264. PlayerSettings.defaultScreenHeight = recommended_DefaultScreenHeight;
  265. }
  266. GUILayout.FlexibleSpace();
  267. if (GUILayout.Button("Ignore"))
  268. {
  269. EditorPrefs.SetBool(ignore + defaultScreenSize, true);
  270. }
  271. GUILayout.EndHorizontal();
  272. }
  273. if (!EditorPrefs.HasKey(ignore + runInBackground) &&
  274. PlayerSettings.runInBackground != recommended_RunInBackground)
  275. {
  276. ++numItems;
  277. GUILayout.Label(runInBackground + string.Format(currentValue, PlayerSettings.runInBackground));
  278. GUILayout.BeginHorizontal();
  279. if (GUILayout.Button(string.Format(useRecommended, recommended_RunInBackground)))
  280. {
  281. PlayerSettings.runInBackground = recommended_RunInBackground;
  282. }
  283. GUILayout.FlexibleSpace();
  284. if (GUILayout.Button("Ignore"))
  285. {
  286. EditorPrefs.SetBool(ignore + runInBackground, true);
  287. }
  288. GUILayout.EndHorizontal();
  289. }
  290. if (!EditorPrefs.HasKey(ignore + displayResolutionDialog) &&
  291. PlayerSettings.displayResolutionDialog != recommended_DisplayResolutionDialog)
  292. {
  293. ++numItems;
  294. GUILayout.Label(displayResolutionDialog + string.Format(currentValue, PlayerSettings.displayResolutionDialog));
  295. GUILayout.BeginHorizontal();
  296. if (GUILayout.Button(string.Format(useRecommended, recommended_DisplayResolutionDialog)))
  297. {
  298. PlayerSettings.displayResolutionDialog = recommended_DisplayResolutionDialog;
  299. }
  300. GUILayout.FlexibleSpace();
  301. if (GUILayout.Button("Ignore"))
  302. {
  303. EditorPrefs.SetBool(ignore + displayResolutionDialog, true);
  304. }
  305. GUILayout.EndHorizontal();
  306. }
  307. if (!EditorPrefs.HasKey(ignore + resizableWindow) &&
  308. PlayerSettings.resizableWindow != recommended_ResizableWindow)
  309. {
  310. ++numItems;
  311. GUILayout.Label(resizableWindow + string.Format(currentValue, PlayerSettings.resizableWindow));
  312. GUILayout.BeginHorizontal();
  313. if (GUILayout.Button(string.Format(useRecommended, recommended_ResizableWindow)))
  314. {
  315. PlayerSettings.resizableWindow = recommended_ResizableWindow;
  316. }
  317. GUILayout.FlexibleSpace();
  318. if (GUILayout.Button("Ignore"))
  319. {
  320. EditorPrefs.SetBool(ignore + resizableWindow, true);
  321. }
  322. GUILayout.EndHorizontal();
  323. }
  324. if (!EditorPrefs.HasKey(ignore + fullscreenMode) &&
  325. PlayerSettings.d3d11FullscreenMode != recommended_FullscreenMode)
  326. {
  327. ++numItems;
  328. GUILayout.Label(fullscreenMode + string.Format(currentValue, PlayerSettings.d3d11FullscreenMode));
  329. GUILayout.BeginHorizontal();
  330. if (GUILayout.Button(string.Format(useRecommended, recommended_FullscreenMode)))
  331. {
  332. PlayerSettings.d3d11FullscreenMode = recommended_FullscreenMode;
  333. }
  334. GUILayout.FlexibleSpace();
  335. if (GUILayout.Button("Ignore"))
  336. {
  337. EditorPrefs.SetBool(ignore + fullscreenMode, true);
  338. }
  339. GUILayout.EndHorizontal();
  340. }
  341. if (!EditorPrefs.HasKey(ignore + visibleInBackground) &&
  342. PlayerSettings.visibleInBackground != recommended_VisibleInBackground)
  343. {
  344. ++numItems;
  345. GUILayout.Label(visibleInBackground + string.Format(currentValue, PlayerSettings.visibleInBackground));
  346. GUILayout.BeginHorizontal();
  347. if (GUILayout.Button(string.Format(useRecommended, recommended_VisibleInBackground)))
  348. {
  349. PlayerSettings.visibleInBackground = recommended_VisibleInBackground;
  350. }
  351. GUILayout.FlexibleSpace();
  352. if (GUILayout.Button("Ignore"))
  353. {
  354. EditorPrefs.SetBool(ignore + visibleInBackground, true);
  355. }
  356. GUILayout.EndHorizontal();
  357. }
  358. #if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
  359. if (!EditorPrefs.HasKey(ignore + renderingPath) &&
  360. PlayerSettings.renderingPath != recommended_RenderPath)
  361. {
  362. ++numItems;
  363. GUILayout.Label(renderingPath + string.Format(currentValue, PlayerSettings.renderingPath));
  364. GUILayout.BeginHorizontal();
  365. if (GUILayout.Button(string.Format(useRecommended, recommended_RenderPath) + " - required for MSAA"))
  366. {
  367. PlayerSettings.renderingPath = recommended_RenderPath;
  368. }
  369. GUILayout.FlexibleSpace();
  370. if (GUILayout.Button("Ignore"))
  371. {
  372. EditorPrefs.SetBool(ignore + renderingPath, true);
  373. }
  374. GUILayout.EndHorizontal();
  375. }
  376. #endif
  377. if (!EditorPrefs.HasKey(ignore + colorSpace) &&
  378. PlayerSettings.colorSpace != recommended_ColorSpace)
  379. {
  380. ++numItems;
  381. GUILayout.Label(colorSpace + string.Format(currentValue, PlayerSettings.colorSpace));
  382. GUILayout.BeginHorizontal();
  383. if (GUILayout.Button(string.Format(useRecommended, recommended_ColorSpace) + " - requires reloading scene"))
  384. {
  385. PlayerSettings.colorSpace = recommended_ColorSpace;
  386. }
  387. GUILayout.FlexibleSpace();
  388. if (GUILayout.Button("Ignore"))
  389. {
  390. EditorPrefs.SetBool(ignore + colorSpace, true);
  391. }
  392. GUILayout.EndHorizontal();
  393. }
  394. if (!EditorPrefs.HasKey(ignore + gpuSkinning) &&
  395. PlayerSettings.gpuSkinning != recommended_GpuSkinning)
  396. {
  397. ++numItems;
  398. GUILayout.Label(gpuSkinning + string.Format(currentValue, PlayerSettings.gpuSkinning));
  399. GUILayout.BeginHorizontal();
  400. if (GUILayout.Button(string.Format(useRecommended, recommended_GpuSkinning)))
  401. {
  402. PlayerSettings.gpuSkinning = recommended_GpuSkinning;
  403. }
  404. GUILayout.FlexibleSpace();
  405. if (GUILayout.Button("Ignore"))
  406. {
  407. EditorPrefs.SetBool(ignore + gpuSkinning, true);
  408. }
  409. GUILayout.EndHorizontal();
  410. }
  411. #if false
  412. if (!EditorPrefs.HasKey(ignore + singlePassStereoRendering) &&
  413. PlayerSettings.singlePassStereoRendering != recommended_SinglePassStereoRendering)
  414. {
  415. ++numItems;
  416. GUILayout.Label(singlePassStereoRendering + string.Format(currentValue, PlayerSettings.singlePassStereoRendering));
  417. GUILayout.BeginHorizontal();
  418. if (GUILayout.Button(string.Format(useRecommended, recommended_SinglePassStereoRendering)))
  419. {
  420. PlayerSettings.singlePassStereoRendering = recommended_SinglePassStereoRendering;
  421. }
  422. GUILayout.FlexibleSpace();
  423. if (GUILayout.Button("Ignore"))
  424. {
  425. EditorPrefs.SetBool(ignore + singlePassStereoRendering, true);
  426. }
  427. GUILayout.EndHorizontal();
  428. }
  429. #endif
  430. GUILayout.BeginHorizontal();
  431. GUILayout.FlexibleSpace();
  432. if (GUILayout.Button("Clear All Ignores"))
  433. {
  434. EditorPrefs.DeleteKey(ignore + buildTarget);
  435. EditorPrefs.DeleteKey(ignore + showUnitySplashScreen);
  436. EditorPrefs.DeleteKey(ignore + defaultIsFullScreen);
  437. EditorPrefs.DeleteKey(ignore + defaultScreenSize);
  438. EditorPrefs.DeleteKey(ignore + runInBackground);
  439. EditorPrefs.DeleteKey(ignore + displayResolutionDialog);
  440. EditorPrefs.DeleteKey(ignore + resizableWindow);
  441. EditorPrefs.DeleteKey(ignore + fullscreenMode);
  442. EditorPrefs.DeleteKey(ignore + visibleInBackground);
  443. #if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
  444. EditorPrefs.DeleteKey(ignore + renderingPath);
  445. #endif
  446. EditorPrefs.DeleteKey(ignore + colorSpace);
  447. EditorPrefs.DeleteKey(ignore + gpuSkinning);
  448. #if false
  449. EditorPrefs.DeleteKey(ignore + singlePassStereoRendering);
  450. #endif
  451. }
  452. GUILayout.EndHorizontal();
  453. GUILayout.EndScrollView();
  454. GUILayout.FlexibleSpace();
  455. GUILayout.BeginHorizontal();
  456. if (numItems > 0)
  457. {
  458. if (GUILayout.Button("Accept All"))
  459. {
  460. // Only set those that have not been explicitly ignored.
  461. if (!EditorPrefs.HasKey(ignore + buildTarget))
  462. #if (UNITY_5_5 || UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
  463. EditorUserBuildSettings.SwitchActiveBuildTarget(recommended_BuildTarget);
  464. #else
  465. EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, recommended_BuildTarget);
  466. #endif
  467. if (!EditorPrefs.HasKey(ignore + showUnitySplashScreen))
  468. #if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
  469. PlayerSettings.showUnitySplashScreen = recommended_ShowUnitySplashScreen;
  470. #else
  471. PlayerSettings.SplashScreen.show = recommended_ShowUnitySplashScreen;
  472. #endif
  473. if (!EditorPrefs.HasKey(ignore + defaultIsFullScreen))
  474. PlayerSettings.defaultIsFullScreen = recommended_DefaultIsFullScreen;
  475. if (!EditorPrefs.HasKey(ignore + defaultScreenSize))
  476. {
  477. PlayerSettings.defaultScreenWidth = recommended_DefaultScreenWidth;
  478. PlayerSettings.defaultScreenHeight = recommended_DefaultScreenHeight;
  479. }
  480. if (!EditorPrefs.HasKey(ignore + runInBackground))
  481. PlayerSettings.runInBackground = recommended_RunInBackground;
  482. if (!EditorPrefs.HasKey(ignore + displayResolutionDialog))
  483. PlayerSettings.displayResolutionDialog = recommended_DisplayResolutionDialog;
  484. if (!EditorPrefs.HasKey(ignore + resizableWindow))
  485. PlayerSettings.resizableWindow = recommended_ResizableWindow;
  486. if (!EditorPrefs.HasKey(ignore + fullscreenMode))
  487. PlayerSettings.d3d11FullscreenMode = recommended_FullscreenMode;
  488. if (!EditorPrefs.HasKey(ignore + visibleInBackground))
  489. PlayerSettings.visibleInBackground = recommended_VisibleInBackground;
  490. #if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
  491. if (!EditorPrefs.HasKey(ignore + renderingPath))
  492. PlayerSettings.renderingPath = recommended_RenderPath;
  493. #endif
  494. if (!EditorPrefs.HasKey(ignore + colorSpace))
  495. PlayerSettings.colorSpace = recommended_ColorSpace;
  496. if (!EditorPrefs.HasKey(ignore + gpuSkinning))
  497. PlayerSettings.gpuSkinning = recommended_GpuSkinning;
  498. #if false
  499. if (!EditorPrefs.HasKey(ignore + singlePassStereoRendering))
  500. PlayerSettings.singlePassStereoRendering = recommended_SinglePassStereoRendering;
  501. #endif
  502. EditorUtility.DisplayDialog("Accept All", "You made the right choice!", "Ok");
  503. Close();
  504. }
  505. if (GUILayout.Button("Ignore All"))
  506. {
  507. if (EditorUtility.DisplayDialog("Ignore All", "Are you sure?", "Yes, Ignore All", "Cancel"))
  508. {
  509. // Only ignore those that do not currently match our recommended settings.
  510. if (EditorUserBuildSettings.activeBuildTarget != recommended_BuildTarget)
  511. EditorPrefs.SetBool(ignore + buildTarget, true);
  512. #if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
  513. if (PlayerSettings.showUnitySplashScreen != recommended_ShowUnitySplashScreen)
  514. #else
  515. if (PlayerSettings.SplashScreen.show != recommended_ShowUnitySplashScreen)
  516. #endif
  517. EditorPrefs.SetBool(ignore + showUnitySplashScreen, true);
  518. if (PlayerSettings.defaultIsFullScreen != recommended_DefaultIsFullScreen)
  519. EditorPrefs.SetBool(ignore + defaultIsFullScreen, true);
  520. if (PlayerSettings.defaultScreenWidth != recommended_DefaultScreenWidth ||
  521. PlayerSettings.defaultScreenHeight != recommended_DefaultScreenHeight)
  522. EditorPrefs.SetBool(ignore + defaultScreenSize, true);
  523. if (PlayerSettings.runInBackground != recommended_RunInBackground)
  524. EditorPrefs.SetBool(ignore + runInBackground, true);
  525. if (PlayerSettings.displayResolutionDialog != recommended_DisplayResolutionDialog)
  526. EditorPrefs.SetBool(ignore + displayResolutionDialog, true);
  527. if (PlayerSettings.resizableWindow != recommended_ResizableWindow)
  528. EditorPrefs.SetBool(ignore + resizableWindow, true);
  529. if (PlayerSettings.d3d11FullscreenMode != recommended_FullscreenMode)
  530. EditorPrefs.SetBool(ignore + fullscreenMode, true);
  531. if (PlayerSettings.visibleInBackground != recommended_VisibleInBackground)
  532. EditorPrefs.SetBool(ignore + visibleInBackground, true);
  533. #if (UNITY_5_4 || UNITY_5_3 || UNITY_5_2 || UNITY_5_1 || UNITY_5_0)
  534. if (PlayerSettings.renderingPath != recommended_RenderPath)
  535. EditorPrefs.SetBool(ignore + renderingPath, true);
  536. #endif
  537. if (PlayerSettings.colorSpace != recommended_ColorSpace)
  538. EditorPrefs.SetBool(ignore + colorSpace, true);
  539. if (PlayerSettings.gpuSkinning != recommended_GpuSkinning)
  540. EditorPrefs.SetBool(ignore + gpuSkinning, true);
  541. #if false
  542. if (PlayerSettings.singlePassStereoRendering != recommended_SinglePassStereoRendering)
  543. EditorPrefs.SetBool(ignore + singlePassStereoRendering, true);
  544. #endif
  545. Close();
  546. }
  547. }
  548. }
  549. else if (GUILayout.Button("Close"))
  550. {
  551. Close();
  552. }
  553. GUILayout.EndHorizontal();
  554. }
  555. }