SteamVR_UnitySettingsWindow.cs 27 KB

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