No Description
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.

PlayerLauncherContextSettings.cs 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using System;
  2. using System.IO;
  3. using UnityEditor.TestTools.TestRunner.Api;
  4. using UnityEngine;
  5. namespace UnityEditor.TestTools.TestRunner
  6. {
  7. internal class PlayerLauncherContextSettings : IDisposable
  8. {
  9. private ITestRunSettings m_OverloadSettings;
  10. private EditorBuildSettingsScene[] m_EditorBuildSettings;
  11. #pragma warning disable 618
  12. private ResolutionDialogSetting m_DisplayResolutionDialog;
  13. #pragma warning restore 618
  14. private bool m_RunInBackground;
  15. private FullScreenMode m_FullScreenMode;
  16. private bool m_ResizableWindow;
  17. private bool m_ShowUnitySplashScreen;
  18. private string m_OldproductName;
  19. private string m_OldAotOptions;
  20. #pragma warning disable 618
  21. private Lightmapping.GIWorkflowMode m_OldLightmapping;
  22. #pragma warning restore 618
  23. private bool m_explicitNullChecks;
  24. private bool m_Disposed;
  25. public PlayerLauncherContextSettings(ITestRunSettings overloadSettings)
  26. {
  27. m_OverloadSettings = overloadSettings;
  28. SetupProjectParameters();
  29. if (overloadSettings != null)
  30. {
  31. overloadSettings.Apply();
  32. }
  33. }
  34. public void Dispose()
  35. {
  36. if (!m_Disposed)
  37. {
  38. CleanupProjectParameters();
  39. if (m_OverloadSettings != null)
  40. {
  41. m_OverloadSettings.Dispose();
  42. }
  43. m_Disposed = true;
  44. }
  45. }
  46. private void SetupProjectParameters()
  47. {
  48. EditorApplication.LockReloadAssemblies();
  49. m_EditorBuildSettings = EditorBuildSettings.scenes;
  50. #pragma warning disable 618
  51. m_DisplayResolutionDialog = PlayerSettings.displayResolutionDialog;
  52. PlayerSettings.displayResolutionDialog = ResolutionDialogSetting.Disabled;
  53. #pragma warning restore 618
  54. m_RunInBackground = PlayerSettings.runInBackground;
  55. PlayerSettings.runInBackground = true;
  56. m_FullScreenMode = PlayerSettings.fullScreenMode;
  57. PlayerSettings.fullScreenMode = FullScreenMode.Windowed;
  58. m_OldAotOptions = PlayerSettings.aotOptions;
  59. PlayerSettings.aotOptions = "nimt-trampolines=1024";
  60. m_ResizableWindow = PlayerSettings.resizableWindow;
  61. PlayerSettings.resizableWindow = true;
  62. m_ShowUnitySplashScreen = PlayerSettings.SplashScreen.show;
  63. PlayerSettings.SplashScreen.show = false;
  64. PlayerSettings.SplashScreen.showUnityLogo = false;
  65. m_OldproductName = PlayerSettings.productName;
  66. PlayerSettings.productName = string.Join("_", Application.productName.Split(Path.GetInvalidFileNameChars()));
  67. #pragma warning disable 618
  68. m_OldLightmapping = Lightmapping.giWorkflowMode;
  69. Lightmapping.giWorkflowMode = Lightmapping.GIWorkflowMode.OnDemand;
  70. #pragma warning restore 618
  71. m_explicitNullChecks = EditorUserBuildSettings.explicitNullChecks;
  72. EditorUserBuildSettings.explicitNullChecks = true;
  73. }
  74. private void CleanupProjectParameters()
  75. {
  76. EditorBuildSettings.scenes = m_EditorBuildSettings;
  77. PlayerSettings.fullScreenMode = m_FullScreenMode;
  78. PlayerSettings.runInBackground = m_RunInBackground;
  79. #pragma warning disable 618
  80. PlayerSettings.displayResolutionDialog = m_DisplayResolutionDialog;
  81. #pragma warning restore 618
  82. PlayerSettings.resizableWindow = m_ResizableWindow;
  83. PlayerSettings.SplashScreen.show = m_ShowUnitySplashScreen;
  84. PlayerSettings.SplashScreen.showUnityLogo = m_ShowUnitySplashScreen;
  85. PlayerSettings.productName = m_OldproductName;
  86. PlayerSettings.aotOptions = m_OldAotOptions;
  87. #pragma warning disable 618
  88. Lightmapping.giWorkflowMode = m_OldLightmapping;
  89. #pragma warning restore 618
  90. EditorUserBuildSettings.explicitNullChecks = m_explicitNullChecks;
  91. EditorApplication.UnlockReloadAssemblies();
  92. }
  93. }
  94. }