RenderStreamingWizard.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. using System;
  2. using System.Linq;
  3. using UnityEditor;
  4. using UnityEditor.Callbacks;
  5. using UnityEngine;
  6. using UnityEngine.InputSystem;
  7. using UnityEngine.Rendering;
  8. using UnityEngine.UIElements;
  9. namespace Unity.RenderStreaming.Editor
  10. {
  11. internal class RenderStreamingWizard : EditorWindow
  12. {
  13. private const string packageName = "com.unity.renderstreaming";
  14. private static readonly BuildTarget[] supportedBuildTarget = {
  15. BuildTarget.StandaloneWindows64,
  16. BuildTarget.StandaloneOSX,
  17. BuildTarget.StandaloneLinux64,
  18. BuildTarget.iOS,
  19. BuildTarget.Android
  20. };
  21. #if UNITY_2021_1_OR_NEWER
  22. const AndroidSdkVersions RequiredAndroidSdkVersion = AndroidSdkVersions.AndroidApiLevel22;
  23. #else
  24. const AndroidSdkVersions RequiredAndroidSdkVersion = AndroidSdkVersions.AndroidApiLevel21;
  25. #endif
  26. private struct ConfigStyle
  27. {
  28. public readonly string label;
  29. public readonly string error;
  30. public readonly string button;
  31. public readonly MessageType messageType;
  32. public ConfigStyle(string label, string error, string button = "Fix",
  33. MessageType messageType = MessageType.Error)
  34. {
  35. this.label = label;
  36. this.error = error;
  37. this.button = button;
  38. this.messageType = messageType;
  39. }
  40. }
  41. static readonly ConfigStyle runInBackground = new ConfigStyle(
  42. label: "Run In Background",
  43. error: "Run In Background must be True for Render Streaming to work in Background.");
  44. static readonly ConfigStyle inputSystemSettingsAssets = new ConfigStyle(
  45. label: "Input System Settings Assets",
  46. error: "Input System Settings asset must exist under the Assets folder for changes.");
  47. static readonly ConfigStyle inputSystemBackgroundBehavior = new ConfigStyle(
  48. label: "InputSystem Background Behavior",
  49. error: "InputSystem Background Behavior must be Ignore Focus for Input System to work in Background.");
  50. static readonly ConfigStyle inputSystemPlayModeInputBehavior = new ConfigStyle(
  51. label: "InputSystem PlayMode Input Behavior",
  52. error: "InputSystem PlayMode Input behavior must be AllDeviceInputAlwaysGoesToGameView for InputSystem to work in background PlayMode.");
  53. static readonly ConfigStyle currentBuildTarget = new ConfigStyle(
  54. label: "Current BuildTarget platform",
  55. error: "Current BuildTarget platform not supported.");
  56. static readonly ConfigStyle currentGraphicsApi = new ConfigStyle(
  57. label: "Current Graphics API",
  58. error: "Current settings contains not support Graphics API.");
  59. static readonly ConfigStyle macCameraUsageDescription = new ConfigStyle(
  60. label: "macOS Camera Usage Description",
  61. error: "Require Camera Usage Description for WebCam access on macOS.");
  62. static readonly ConfigStyle macMicrophoneUsageDescription = new ConfigStyle(
  63. label: "macOS Microphone Usage Description",
  64. error: "Require Microphone Usage Description for Microphone access on macOS.");
  65. static readonly ConfigStyle iOSCameraUsageDescription = new ConfigStyle(
  66. label: "iOS Camera Usage Description",
  67. error: "Require Camera Usage Description for WebCam access on iOS.");
  68. static readonly ConfigStyle iOSMicrophoneUsageDescription = new ConfigStyle(
  69. label: "iOS Microphone Usage Description",
  70. error: "Require Microphone Usage Description for Microphone access on iOS.");
  71. static readonly ConfigStyle androidMinimumAPILevel = new ConfigStyle(
  72. label: "Android Minimum API Level",
  73. error: $"The minimum Android SDK level required is {(int)RequiredAndroidSdkVersion} or higher.");
  74. static readonly ConfigStyle androidScriptBackend = new ConfigStyle(
  75. label: "Android Script Backend",
  76. error: "Render Streaming only supports IL2CPP as a scripting backend.");
  77. static readonly ConfigStyle androidTargetArchitecture = new ConfigStyle(
  78. label: "Android Target Architecture",
  79. error: "Render Streaming only supported ARM64 as a Android Target Architecture.");
  80. static readonly ConfigStyle androidInternetAccess = new ConfigStyle(
  81. label: "Android Internet Access",
  82. error: "InternetAccess must be set Required on Android.");
  83. enum Scope
  84. {
  85. PlayMode,
  86. BuildSettings
  87. }
  88. struct Entry
  89. {
  90. public delegate bool Checker();
  91. public delegate void Fixer();
  92. public delegate bool DependChecker();
  93. public readonly Scope scope;
  94. public readonly ConfigStyle configStyle;
  95. public readonly Checker check;
  96. public readonly Fixer fix;
  97. public readonly DependChecker dependChecker;
  98. public readonly bool forceDisplayCheck;
  99. public readonly bool skipErrorIcon;
  100. public Entry(
  101. Scope scope,
  102. ConfigStyle configStyle,
  103. Checker check,
  104. Fixer fix,
  105. DependChecker dependChecker = null,
  106. bool forceDisplayCheck = false,
  107. bool skipErrorIcon = false
  108. )
  109. {
  110. this.scope = scope;
  111. this.configStyle = configStyle;
  112. this.check = check;
  113. this.fix = fix;
  114. this.dependChecker = dependChecker;
  115. this.forceDisplayCheck = forceDisplayCheck;
  116. this.skipErrorIcon = skipErrorIcon;
  117. }
  118. }
  119. private Entry[] entries;
  120. Entry[] Entries
  121. {
  122. get
  123. {
  124. // due to functor, cannot static link directly in an array and need lazy init
  125. if (entries == null)
  126. entries = new[]
  127. {
  128. new Entry(Scope.PlayMode, runInBackground, IsRunInBackgroundCorrect, FixRunInBackground),
  129. new Entry(Scope.PlayMode, inputSystemSettingsAssets, IsInputSettingsAssetsExists, FixInputSettingsAssets),
  130. new Entry(Scope.PlayMode, inputSystemBackgroundBehavior,
  131. IsInputSystemBackgroundBehaviorCorrect,
  132. FixInputSystemBackgroundBehavior,
  133. IsInputSettingsAssetsExists),
  134. new Entry(Scope.PlayMode, inputSystemPlayModeInputBehavior,
  135. IsInputSystemPlayModeInputBehaviorCorrect,
  136. FixInputSystemPlayModeInputBehavior,
  137. IsInputSettingsAssetsExists),
  138. new Entry(Scope.BuildSettings, currentBuildTarget, IsSupportedBuildTarget, FixSupportedBuildTarget),
  139. new Entry(Scope.BuildSettings, currentGraphicsApi, IsSupportedGraphics, FixSupportedGraphics),
  140. new Entry(Scope.BuildSettings, macCameraUsageDescription, IsMacCameraUsageCorrect, FixMacCameraUsage),
  141. new Entry(Scope.BuildSettings, macMicrophoneUsageDescription, IsMacMicrophoneUsageCorrect,
  142. FixMacMicrophoneUsage),
  143. new Entry(Scope.BuildSettings, iOSCameraUsageDescription, IsIOSCameraUsageCorrect, FixIOSCameraUsage),
  144. new Entry(Scope.BuildSettings, iOSMicrophoneUsageDescription, IsIOSMicrophoneUsageCorrect,
  145. FixIOSMicrophoneUsage),
  146. new Entry(Scope.BuildSettings, androidMinimumAPILevel, IsAndroidMinimumAPILevelCorrect,
  147. FixAndroidMinimumAPILevel),
  148. new Entry(Scope.BuildSettings, androidScriptBackend, IsAndroidScriptBackendCorrect,
  149. FixAndroidScriptBackend),
  150. new Entry(Scope.BuildSettings, androidTargetArchitecture, IsAndroidTargetArchitectureCorrect,
  151. FixAndroidTargetArchitecture),
  152. new Entry(Scope.BuildSettings, androidInternetAccess, IsAndroidInternetAccessCorrect,
  153. FixAndroidInternetAccess),
  154. };
  155. return entries;
  156. }
  157. }
  158. private static bool IsRunInBackgroundCorrect() => PlayerSettings.runInBackground;
  159. private static void FixRunInBackground() => PlayerSettings.runInBackground = true;
  160. private static bool IsInputSettingsAssetsExists()
  161. {
  162. var path = AssetDatabase.GetAssetPath(UnityEngine.InputSystem.InputSystem.settings);
  163. return !string.IsNullOrEmpty(path) && path.StartsWith("Assets/");
  164. }
  165. private static void FixInputSettingsAssets()
  166. {
  167. var inputSettings = CreateInstance<InputSettings>();
  168. AssetDatabase.CreateAsset(inputSettings, $"Assets/{PlayerSettings.productName}.inputsettings.asset");
  169. UnityEngine.InputSystem.InputSystem.settings = inputSettings;
  170. }
  171. private static bool IsInputSystemBackgroundBehaviorCorrect() =>
  172. UnityEngine.InputSystem.InputSystem.settings.backgroundBehavior == InputSettings.BackgroundBehavior.IgnoreFocus;
  173. private static void FixInputSystemBackgroundBehavior()
  174. {
  175. UnityEngine.InputSystem.InputSystem.settings.backgroundBehavior = InputSettings.BackgroundBehavior.IgnoreFocus;
  176. EditorUtility.SetDirty(UnityEngine.InputSystem.InputSystem.settings);
  177. }
  178. private static bool IsInputSystemPlayModeInputBehaviorCorrect() =>
  179. UnityEngine.InputSystem.InputSystem.settings.editorInputBehaviorInPlayMode ==
  180. InputSettings.EditorInputBehaviorInPlayMode.AllDeviceInputAlwaysGoesToGameView;
  181. private static void FixInputSystemPlayModeInputBehavior()
  182. {
  183. UnityEngine.InputSystem.InputSystem.settings.editorInputBehaviorInPlayMode = InputSettings.EditorInputBehaviorInPlayMode.AllDeviceInputAlwaysGoesToGameView;
  184. EditorUtility.SetDirty(UnityEngine.InputSystem.InputSystem.settings);
  185. }
  186. private static bool IsSupportedBuildTarget()
  187. {
  188. var correctBuildTarget = supportedBuildTarget.Contains(EditorUserBuildSettings.activeBuildTarget);
  189. #if UNITY_2021_1_OR_NEWER
  190. correctBuildTarget = correctBuildTarget && EditorUserBuildSettings.standaloneBuildSubtarget == StandaloneBuildSubtarget.Player;
  191. #endif
  192. return correctBuildTarget;
  193. }
  194. private static void FixSupportedBuildTarget()
  195. {
  196. BuildTarget target = default;
  197. #if UNITY_EDITOR_WIN
  198. target = BuildTarget.StandaloneWindows64;
  199. #elif UNITY_EDITOR_OSX
  200. target = BuildTarget.StandaloneOSX;
  201. #elif UNITY_EDITOR_LINUX
  202. target = BuildTarget.StandaloneLinux64;
  203. #else
  204. throw new NotSupportedException();
  205. #endif
  206. EditorUserBuildSettings.SwitchActiveBuildTarget(BuildPipeline.GetBuildTargetGroup(target), target);
  207. #if UNITY_2021_1_OR_NEWER
  208. EditorUserBuildSettings.standaloneBuildSubtarget = StandaloneBuildSubtarget.Player;
  209. #endif
  210. }
  211. private static bool IsSupportedGraphics() => supportedBuildTarget.All(CheckGraphicsApi);
  212. private static bool CheckGraphicsApi(BuildTarget target)
  213. {
  214. var targetGraphics = PlayerSettings.GetGraphicsAPIs(target);
  215. switch (target)
  216. {
  217. case BuildTarget.StandaloneOSX:
  218. case BuildTarget.iOS:
  219. return targetGraphics.All(x => x == GraphicsDeviceType.Metal);
  220. case BuildTarget.Android:
  221. return targetGraphics.All(x => x == GraphicsDeviceType.OpenGLES3 || x == GraphicsDeviceType.Vulkan);
  222. case BuildTarget.StandaloneWindows64:
  223. return targetGraphics.All(x => x == GraphicsDeviceType.Direct3D11 || x == GraphicsDeviceType.Direct3D12 || x == GraphicsDeviceType.Vulkan);
  224. case BuildTarget.StandaloneLinux64:
  225. return targetGraphics.All(x => x == GraphicsDeviceType.OpenGLCore || x == GraphicsDeviceType.Vulkan);
  226. default:
  227. return false;
  228. }
  229. }
  230. private static void FixSupportedGraphics()
  231. {
  232. foreach (var target in supportedBuildTarget.Where(x => !CheckGraphicsApi(x)))
  233. {
  234. switch (target)
  235. {
  236. case BuildTarget.StandaloneOSX:
  237. case BuildTarget.iOS:
  238. PlayerSettings.SetGraphicsAPIs(target, new[] {GraphicsDeviceType.Metal});
  239. break;
  240. case BuildTarget.Android:
  241. PlayerSettings.SetGraphicsAPIs(target, new[] {GraphicsDeviceType.OpenGLES3, GraphicsDeviceType.Vulkan});
  242. break;
  243. case BuildTarget.StandaloneWindows64:
  244. PlayerSettings.SetGraphicsAPIs(target, new[] {GraphicsDeviceType.Direct3D11, GraphicsDeviceType.Direct3D12, GraphicsDeviceType.Vulkan});
  245. break;
  246. case BuildTarget.StandaloneLinux64:
  247. PlayerSettings.SetGraphicsAPIs(target, new[] {GraphicsDeviceType.OpenGLCore, GraphicsDeviceType.Vulkan});
  248. break;
  249. default:
  250. throw new NotSupportedException($"{nameof(target)} is not supported.");
  251. }
  252. }
  253. }
  254. private static bool IsMacCameraUsageCorrect() =>
  255. !string.IsNullOrEmpty(PlayerSettings.macOS.cameraUsageDescription);
  256. private static void FixMacCameraUsage() => PlayerSettings.macOS.cameraUsageDescription = "For WebCamTexture";
  257. private static bool IsMacMicrophoneUsageCorrect() =>
  258. !string.IsNullOrEmpty(PlayerSettings.iOS.microphoneUsageDescription);
  259. private static void FixMacMicrophoneUsage() => PlayerSettings.iOS.microphoneUsageDescription = "For Microphone";
  260. private static bool IsIOSCameraUsageCorrect() =>
  261. !string.IsNullOrEmpty(PlayerSettings.iOS.cameraUsageDescription);
  262. private static void FixIOSCameraUsage() => PlayerSettings.iOS.cameraUsageDescription = "For WebCamTexture";
  263. private static bool IsIOSMicrophoneUsageCorrect() =>
  264. !string.IsNullOrEmpty(PlayerSettings.iOS.microphoneUsageDescription);
  265. private static void FixIOSMicrophoneUsage() => PlayerSettings.iOS.microphoneUsageDescription = "For Microphone";
  266. private static bool IsAndroidMinimumAPILevelCorrect() =>
  267. PlayerSettings.Android.minSdkVersion >= RequiredAndroidSdkVersion;
  268. private static void FixAndroidMinimumAPILevel() =>
  269. PlayerSettings.Android.minSdkVersion = RequiredAndroidSdkVersion;
  270. private static bool IsAndroidScriptBackendCorrect() =>
  271. PlayerSettings.GetScriptingBackend(BuildTargetGroup.Android) == ScriptingImplementation.IL2CPP;
  272. private static void FixAndroidScriptBackend() =>
  273. PlayerSettings.SetScriptingBackend(BuildTargetGroup.Android, ScriptingImplementation.IL2CPP);
  274. private static bool IsAndroidTargetArchitectureCorrect() =>
  275. PlayerSettings.Android.targetArchitectures == AndroidArchitecture.ARM64;
  276. private static void FixAndroidTargetArchitecture() =>
  277. PlayerSettings.Android.targetArchitectures = AndroidArchitecture.ARM64;
  278. private static bool IsAndroidInternetAccessCorrect() => PlayerSettings.Android.forceInternetPermission;
  279. private static void FixAndroidInternetAccess() => PlayerSettings.Android.forceInternetPermission = true;
  280. const string kTemplatePath = "Packages/com.unity.renderstreaming/Editor/UXML/RenderStreamingWizard.uxml";
  281. const string kStylePath = "Packages/com.unity.renderstreaming/Editor/Styles/RenderStreamingWizard.uss";
  282. [MenuItem("Window/Render Streaming/Render Streaming Wizard", priority = 10000)]
  283. static void OpenWindow()
  284. {
  285. var window = GetWindow<RenderStreamingWizard>("Render Streaming Wizard");
  286. window.minSize = new Vector2(500, 450);
  287. RenderStreamingProjectSettings.wizardPopupAlreadyShownOnce = true;
  288. }
  289. static RenderStreamingWizard()
  290. {
  291. WizardBehaviour();
  292. }
  293. private static int frameToWait;
  294. private static void WizardBehaviourDelayed()
  295. {
  296. if (frameToWait > 0)
  297. --frameToWait;
  298. else
  299. {
  300. EditorApplication.update -= WizardBehaviourDelayed;
  301. if (RenderStreamingProjectSettings.wizardIsStartPopup &&
  302. !RenderStreamingProjectSettings.wizardPopupAlreadyShownOnce)
  303. {
  304. //Application.isPlaying cannot be called in constructor. Do it here
  305. if (Application.isPlaying)
  306. return;
  307. OpenWindow();
  308. }
  309. EditorApplication.quitting += () => RenderStreamingProjectSettings.wizardPopupAlreadyShownOnce = false;
  310. }
  311. }
  312. [DidReloadScripts]
  313. static void CheckPersistentPopupAlreadyOpened()
  314. {
  315. EditorApplication.delayCall += () =>
  316. {
  317. if (RenderStreamingProjectSettings.wizardPopupAlreadyShownOnce)
  318. EditorApplication.quitting +=
  319. () => RenderStreamingProjectSettings.wizardPopupAlreadyShownOnce = false;
  320. };
  321. }
  322. [DidReloadScripts]
  323. static void WizardBehaviour()
  324. {
  325. //We need to wait at least one frame or the popup will not show up
  326. frameToWait = 10;
  327. EditorApplication.update += WizardBehaviourDelayed;
  328. }
  329. private void OnEnable()
  330. {
  331. var styleSheet = EditorGUIUtility.Load(kStylePath) as StyleSheet;
  332. var uiAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(kTemplatePath);
  333. var newVisualElement = new VisualElement();
  334. uiAsset.CloneTree(newVisualElement);
  335. rootVisualElement.Add(newVisualElement);
  336. rootVisualElement.styleSheets.Add(styleSheet);
  337. BindCheckVersion();
  338. BindCurrentSettings();
  339. BindChecker();
  340. BindWebApp();
  341. BindCheckBox();
  342. }
  343. private int inspectorCounter = 0;
  344. private Label currentSettingsLabel;
  345. private HelpBox currentSettingsHelpBox;
  346. private Button fixAllButton;
  347. private VisualElement playmodeCheckButtons;
  348. private VisualElement buildSettingsCheckButtons;
  349. private void OnInspectorUpdate()
  350. {
  351. // limit inspector update per 1 second.
  352. inspectorCounter++;
  353. if (inspectorCounter % 10 != 0)
  354. {
  355. return;
  356. }
  357. if (currentSettingsLabel != null)
  358. {
  359. currentSettingsLabel.text = $"Current Render Streaming Settings: {GetSettingsAssetName()}";
  360. }
  361. if (currentSettingsHelpBox != null)
  362. {
  363. currentSettingsHelpBox.style.display = IsDefaultSetting() ? DisplayStyle.Flex : DisplayStyle.None;
  364. }
  365. fixAllButton?.SetEnabled(entries.Any(x => !x.check()));
  366. if (playmodeCheckButtons != null && buildSettingsCheckButtons != null)
  367. {
  368. foreach (var visualElement in playmodeCheckButtons.Children()
  369. .Concat(buildSettingsCheckButtons.Children())
  370. .Select(c => c as ConfigInfoLine)
  371. .Where(c => c != null))
  372. {
  373. visualElement.CheckUpdate();
  374. }
  375. }
  376. inspectorCounter = 0;
  377. }
  378. private void BindCheckVersion()
  379. {
  380. var checkUpdateContainer = rootVisualElement.Q("checkUpdateContainer");
  381. var label = new TextElement {text = "Current Render Streaming version: checking..."};
  382. checkUpdateContainer.Add(label);
  383. var button = new Button(() =>
  384. UnityEditor.PackageManager.UI.Window.Open(packageName)) {text = "Check update"};
  385. button.AddToClassList("right-anchored-button");
  386. checkUpdateContainer.Add(button);
  387. RequestJobManager.CreateListRequest(true, true, (req) =>
  388. {
  389. var packageInfo = req.FindPackage(packageName);
  390. if (null == packageInfo)
  391. {
  392. Debug.LogError($"Not found package \"{packageName}\"");
  393. return;
  394. }
  395. label.text = $"Current Render Streaming version: {packageInfo.version}";
  396. }, null);
  397. }
  398. private void BindCurrentSettings()
  399. {
  400. var checkUpdateContainer = rootVisualElement.Q("currentSettingsContainer");
  401. currentSettingsLabel = new Label {text = $"Current Render Streaming Settings: {GetSettingsAssetName()}"};
  402. currentSettingsLabel.AddToClassList("normal");
  403. checkUpdateContainer.Add(currentSettingsLabel);
  404. var button = new Button(() => SettingsService.OpenProjectSettings("Project/Render Streaming"))
  405. {
  406. text = "Open Project Settings"
  407. };
  408. button.AddToClassList(("open-project-settings"));
  409. checkUpdateContainer.Add(button);
  410. currentSettingsHelpBox = new HelpBox("Current selected settings is default. If you want to change settings, open the Project Window and create or select another Settings.", HelpBoxMessageType.Info)
  411. {
  412. style = {display = IsDefaultSetting() ? DisplayStyle.Flex : DisplayStyle.None}
  413. };
  414. checkUpdateContainer.Add(currentSettingsHelpBox);
  415. }
  416. private static string GetSettingsAssetName()
  417. {
  418. var path = AssetDatabase.GetAssetPath(RenderStreaming.Settings);
  419. var assetName = path == RenderStreaming.DefaultRenderStreamingSettingsPath ? "Default" : path.Split('/').Last();
  420. return assetName;
  421. }
  422. private static bool IsDefaultSetting()
  423. {
  424. return AssetDatabase.GetAssetPath(RenderStreaming.Settings) == RenderStreaming.DefaultRenderStreamingSettingsPath;
  425. }
  426. private void BindChecker()
  427. {
  428. fixAllButton = rootVisualElement.Q<Button>("fixAllButton");
  429. playmodeCheckButtons = rootVisualElement.Q("playmodeCheckButtons");
  430. buildSettingsCheckButtons = rootVisualElement.Q("buildSettingsCheckButtons");
  431. fixAllButton.clickable.clicked += () =>
  432. {
  433. foreach (var entry in Entries.Where(x => !x.check()))
  434. {
  435. entry.fix();
  436. }
  437. };
  438. foreach (var entry in Entries.Where(x => x.scope == Scope.PlayMode))
  439. {
  440. playmodeCheckButtons.Add(new ConfigInfoLine(
  441. entry.configStyle.label,
  442. entry.configStyle.error,
  443. entry.configStyle.messageType,
  444. entry.configStyle.button,
  445. () => entry.check(),
  446. entry.fix == null ? (Action)null : () => entry.fix(),
  447. entry.dependChecker == null ? (Func<bool>)null : () => entry.dependChecker(),
  448. entry.configStyle.messageType == MessageType.Error || entry.forceDisplayCheck,
  449. entry.skipErrorIcon));
  450. }
  451. foreach (var entry in Entries.Where(x => x.scope == Scope.BuildSettings))
  452. {
  453. buildSettingsCheckButtons.Add(new ConfigInfoLine(
  454. entry.configStyle.label,
  455. entry.configStyle.error,
  456. entry.configStyle.messageType,
  457. entry.configStyle.button,
  458. () => entry.check(),
  459. entry.fix == null ? (Action)null : () => entry.fix(),
  460. entry.dependChecker == null ? (Func<bool>)null : () => entry.dependChecker(),
  461. entry.configStyle.messageType == MessageType.Error || entry.forceDisplayCheck,
  462. entry.skipErrorIcon));
  463. }
  464. }
  465. private void BindWebApp()
  466. {
  467. var webappContainer = rootVisualElement.Q("webappContainer");
  468. var webappButton = new Button(() =>
  469. {
  470. WebAppDownloader.GetPackageVersion(packageName, (version) =>
  471. {
  472. var dstPath = EditorUtility.OpenFolderPanel("Select download folder", "", "");
  473. WebAppDownloader.DownloadWebApp(version, dstPath, null);
  474. });
  475. }) {text = "Download latest version web app."};
  476. webappButton.AddToClassList("large-button");
  477. var showWebAppDocButton = new Button(() =>
  478. {
  479. WebAppDownloader.GetPackageVersion(packageName, (version) =>
  480. {
  481. var url = WebAppDownloader.GetURLDocumentation(version);
  482. Application.OpenURL(url);
  483. });
  484. }) {text = "Show web app documentation."};
  485. showWebAppDocButton.AddToClassList("large-button");
  486. var showWebAppSourceButton = new Button(() =>
  487. {
  488. WebAppDownloader.GetPackageVersion(packageName, (version) =>
  489. {
  490. var url = WebAppDownloader.GetURLSourceCode(version);
  491. Application.OpenURL(url);
  492. });
  493. }) {text = "Show web app source code."};
  494. showWebAppSourceButton.AddToClassList("large-button");
  495. webappContainer.Add(webappButton);
  496. webappContainer.Add(showWebAppDocButton);
  497. webappContainer.Add(showWebAppSourceButton);
  498. }
  499. private void BindCheckBox()
  500. {
  501. var wizardCheckboxContainer = rootVisualElement.Q("wizardCheckboxContainer");
  502. var wizardCheckbox = new Toggle("Show on start")
  503. {
  504. name = "wizardCheckbox"
  505. };
  506. wizardCheckbox.SetValueWithoutNotify(RenderStreamingProjectSettings.wizardIsStartPopup);
  507. wizardCheckbox.RegisterValueChangedCallback(evt
  508. => RenderStreamingProjectSettings.wizardIsStartPopup = evt.newValue);
  509. wizardCheckboxContainer.Add(wizardCheckbox);
  510. }
  511. }
  512. }