2
0

SteamVR_UnitySettingsWindow.cs 27 KB

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