HotReloadRunTab.cs 73 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using SingularityGroup.HotReload.DTO;
  5. using SingularityGroup.HotReload.EditorDependencies;
  6. using UnityEditor;
  7. using UnityEditor.Compilation;
  8. using UnityEngine;
  9. using Color = UnityEngine.Color;
  10. using Task = System.Threading.Tasks.Task;
  11. #if UNITY_2019_4_OR_NEWER
  12. using Unity.CodeEditor;
  13. #endif
  14. namespace SingularityGroup.HotReload.Editor {
  15. internal class ErrorData {
  16. public string fileName;
  17. public string error;
  18. public TextAsset file;
  19. public int lineNumber;
  20. public string stacktrace;
  21. public string linkString;
  22. private static string[] supportedPaths = new[] { Path.GetFullPath("Assets"), Path.GetFullPath("Plugins") };
  23. public static ErrorData GetErrorData(string errorString) {
  24. // Get the relevant file name
  25. string stackTrace = errorString;
  26. string fileName = null;
  27. try {
  28. int csIndex = 0;
  29. int attempt = 0;
  30. do {
  31. csIndex = errorString.IndexOf(".cs", csIndex + 1, StringComparison.Ordinal);
  32. if (csIndex == -1) {
  33. break;
  34. }
  35. int fileNameStartIndex = csIndex - 1;
  36. for (; fileNameStartIndex >= 0; fileNameStartIndex--) {
  37. if (!char.IsLetter(errorString[fileNameStartIndex])) {
  38. if (errorString.Contains("error CS")) {
  39. fileName = errorString.Substring(fileNameStartIndex + 1,
  40. csIndex - fileNameStartIndex + ".cs".Length - 1);
  41. } else {
  42. fileName = errorString.Substring(fileNameStartIndex,
  43. csIndex - fileNameStartIndex + ".cs".Length);
  44. }
  45. break;
  46. }
  47. }
  48. } while (attempt++ < 100 && fileName == null);
  49. } catch {
  50. // ignore
  51. }
  52. fileName = fileName ?? "Tap to show stacktrace";
  53. // Get the error
  54. string error = (errorString.Contains("error CS")
  55. ? "Compile error, "
  56. : "Unsupported change detected, ") + "tap here to see more.";
  57. int endOfError = errorString.IndexOf(". in ", StringComparison.Ordinal);
  58. string specialChars = "\"'/\\";
  59. char[] characters = specialChars.ToCharArray();
  60. int specialChar = errorString.IndexOfAny(characters);
  61. try {
  62. if (errorString.Contains("error CS") ) {
  63. error = errorString.Substring(errorString.IndexOf("error CS", StringComparison.Ordinal), errorString.Length - errorString.IndexOf("error CS", StringComparison.Ordinal)).Trim();
  64. using (StringReader reader = new StringReader(error)) {
  65. string line;
  66. while ((line = reader.ReadLine()) != null) {
  67. error = line;
  68. break;
  69. }
  70. }
  71. } else if (errorString.StartsWith("errors:", StringComparison.Ordinal) && endOfError > 0) {
  72. error = errorString.Substring("errors: ".Length, endOfError - "errors: ".Length).Trim();
  73. } else if (errorString.StartsWith("errors:", StringComparison.Ordinal) && specialChar > 0) {
  74. error = errorString.Substring("errors: ".Length, specialChar - "errors: ".Length).Trim();
  75. }
  76. } catch {
  77. // ignore
  78. }
  79. // Get relative path
  80. TextAsset file = null;
  81. try {
  82. foreach (var path in supportedPaths) {
  83. int lastprojectIndex = 0;
  84. int attempt = 0;
  85. while (attempt++ < 100 && !file) {
  86. lastprojectIndex = errorString.IndexOf(path, lastprojectIndex + 1, StringComparison.Ordinal);
  87. if (lastprojectIndex == -1) {
  88. break;
  89. }
  90. var fullCsIndex = errorString.IndexOf(".cs", lastprojectIndex, StringComparison.Ordinal);
  91. var l = fullCsIndex - lastprojectIndex + ".cs".Length;
  92. if (l <= 0) {
  93. continue;
  94. }
  95. var candidateAbsolutePath = errorString.Substring(lastprojectIndex, fullCsIndex - lastprojectIndex + ".cs".Length);
  96. var candidateRelativePath = EditorCodePatcher.GetRelativePath(filespec: candidateAbsolutePath, folder: path);
  97. file = AssetDatabase.LoadAssetAtPath<TextAsset>(candidateRelativePath);
  98. }
  99. }
  100. } catch {
  101. // ignore
  102. }
  103. // Get the line number
  104. int lineNumber = 0;
  105. try {
  106. int lastIndex = 0;
  107. int attempt = 0;
  108. do {
  109. lastIndex = errorString.IndexOf(fileName, lastIndex + 1, StringComparison.Ordinal);
  110. if (lastIndex == -1) {
  111. break;
  112. }
  113. var part = errorString.Substring(lastIndex + fileName.Length);
  114. if (!part.StartsWith(errorString.Contains("error CS") ? "(" : ":", StringComparison.Ordinal)
  115. || part.Length == 1
  116. || !char.IsDigit(part[1])
  117. ) {
  118. continue;
  119. }
  120. int y = 1;
  121. for (; y < part.Length; y++) {
  122. if (!char.IsDigit(part[y])) {
  123. break;
  124. }
  125. }
  126. if (int.TryParse(part.Substring(1, errorString.Contains("error CS") ? y - 1 : y), out lineNumber)) {
  127. break;
  128. }
  129. } while (attempt++ < 100);
  130. } catch {
  131. //ignore
  132. }
  133. return new ErrorData() {
  134. fileName = fileName,
  135. error = error,
  136. file = file,
  137. lineNumber = lineNumber,
  138. stacktrace = stackTrace,
  139. linkString = lineNumber > 0 ? fileName + ":" + lineNumber : fileName
  140. };
  141. }
  142. }
  143. internal struct HotReloadRunTabState {
  144. public readonly bool spinnerActive;
  145. public readonly string indicationIconPath;
  146. public readonly bool requestingDownloadAndRun;
  147. public readonly bool starting;
  148. public readonly bool stopping;
  149. public readonly bool running;
  150. public readonly Tuple<float, string> startupProgress;
  151. public readonly string indicationStatusText;
  152. public readonly LoginStatusResponse loginStatus;
  153. public readonly bool downloadRequired;
  154. public readonly bool downloadStarted;
  155. public readonly bool requestingLoginInfo;
  156. public readonly RedeemStage redeemStage;
  157. public readonly int suggestionCount;
  158. public HotReloadRunTabState(
  159. bool spinnerActive,
  160. string indicationIconPath,
  161. bool requestingDownloadAndRun,
  162. bool starting,
  163. bool stopping,
  164. bool running,
  165. Tuple<float, string> startupProgress,
  166. string indicationStatusText,
  167. LoginStatusResponse loginStatus,
  168. bool downloadRequired,
  169. bool downloadStarted,
  170. bool requestingLoginInfo,
  171. RedeemStage redeemStage,
  172. int suggestionCount
  173. ) {
  174. this.spinnerActive = spinnerActive;
  175. this.indicationIconPath = indicationIconPath;
  176. this.requestingDownloadAndRun = requestingDownloadAndRun;
  177. this.starting = starting;
  178. this.stopping = stopping;
  179. this.running = running;
  180. this.startupProgress = startupProgress;
  181. this.indicationStatusText = indicationStatusText;
  182. this.loginStatus = loginStatus;
  183. this.downloadRequired = downloadRequired;
  184. this.downloadStarted = downloadStarted;
  185. this.requestingLoginInfo = requestingLoginInfo;
  186. this.redeemStage = redeemStage;
  187. this.suggestionCount = suggestionCount;
  188. }
  189. public static HotReloadRunTabState Current => new HotReloadRunTabState(
  190. spinnerActive: EditorIndicationState.SpinnerActive,
  191. indicationIconPath: EditorIndicationState.IndicationIconPath,
  192. requestingDownloadAndRun: EditorCodePatcher.RequestingDownloadAndRun,
  193. starting: EditorCodePatcher.Starting,
  194. stopping: EditorCodePatcher.Stopping,
  195. running: EditorCodePatcher.Running,
  196. startupProgress: EditorCodePatcher.StartupProgress,
  197. indicationStatusText: EditorIndicationState.IndicationStatusText,
  198. loginStatus: EditorCodePatcher.Status,
  199. downloadRequired: EditorCodePatcher.DownloadRequired,
  200. downloadStarted: EditorCodePatcher.DownloadStarted,
  201. requestingLoginInfo: EditorCodePatcher.RequestingLoginInfo,
  202. redeemStage: RedeemLicenseHelper.I.RedeemStage,
  203. suggestionCount: HotReloadTimelineHelper.Suggestions.Count
  204. );
  205. }
  206. internal struct LicenseErrorData {
  207. public readonly string description;
  208. public bool showBuyButton;
  209. public string buyButtonText;
  210. public readonly bool showLoginButton;
  211. public readonly string loginButtonText;
  212. public readonly bool showSupportButton;
  213. public readonly string supportButtonText;
  214. public readonly bool showManageLicenseButton;
  215. public readonly string manageLicenseButtonText;
  216. public LicenseErrorData(string description, bool showManageLicenseButton = false, string manageLicenseButtonText = "", string loginButtonText = "", bool showSupportButton = false, string supportButtonText = "", bool showBuyButton = false, string buyButtonText = "", bool showLoginButton = false) {
  217. this.description = description;
  218. this.showManageLicenseButton = showManageLicenseButton;
  219. this.manageLicenseButtonText = manageLicenseButtonText;
  220. this.loginButtonText = loginButtonText;
  221. this.showSupportButton = showSupportButton;
  222. this.supportButtonText = supportButtonText;
  223. this.showBuyButton = showBuyButton;
  224. this.buyButtonText = buyButtonText;
  225. this.showLoginButton = showLoginButton;
  226. }
  227. }
  228. internal class HotReloadRunTab : HotReloadTabBase {
  229. private static string _pendingEmail;
  230. private static string _pendingPassword;
  231. private string _pendingPromoCode;
  232. private bool _requestingActivatePromoCode;
  233. private static Tuple<string, MessageType> _activateInfoMessage;
  234. private HotReloadRunTabState currentState => _window.RunTabState;
  235. // Has Indie or Pro license (even if not currenctly active)
  236. public bool HasPayedLicense => currentState.loginStatus != null && (currentState.loginStatus.isIndieLicense || currentState.loginStatus.isBusinessLicense);
  237. public bool TrialLicense => currentState.loginStatus != null && (currentState.loginStatus?.isTrial == true);
  238. private Vector2 _patchedMethodsScrollPos;
  239. private Vector2 _runTabScrollPos;
  240. private string promoCodeError;
  241. private MessageType promoCodeErrorType;
  242. private bool promoCodeActivatedThisSession;
  243. public HotReloadRunTab(HotReloadWindow window) : base(window, "Run", "forward", "Run and monitor the current Hot Reload session.") { }
  244. public override void OnGUI() {
  245. using(new EditorGUILayout.VerticalScope()) {
  246. OnGUICore();
  247. }
  248. }
  249. internal static bool ShouldRenderConsumption(HotReloadRunTabState currentState) => (currentState.running && !currentState.starting && !currentState.stopping && currentState.loginStatus?.isLicensed != true && currentState.loginStatus?.isFree != true && !EditorCodePatcher.LoginNotRequired) && !(currentState.loginStatus == null || currentState.loginStatus.isFree);
  250. void OnGUICore() {
  251. using (var scope = new EditorGUILayout.ScrollViewScope(_runTabScrollPos, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar, GUILayout.MaxHeight(Math.Max(HotReloadWindowStyles.windowScreenHeight, 800)), GUILayout.MaxWidth(Math.Max(HotReloadWindowStyles.windowScreenWidth, 800)))) {
  252. _runTabScrollPos.x = scope.scrollPosition.x;
  253. _runTabScrollPos.y = scope.scrollPosition.y;
  254. using (new EditorGUILayout.VerticalScope(HotReloadWindowStyles.DynamiSection)) {
  255. if (HotReloadWindowStyles.windowScreenWidth > Constants.UpgradeLicenseNoteHideWidth
  256. && HotReloadWindowStyles.windowScreenHeight > Constants.UpgradeLicenseNoteHideHeight
  257. ) {
  258. RenderUpgradeLicenseNote(currentState, HotReloadWindowStyles.UpgradeLicenseButtonStyle);
  259. }
  260. RenderIndicationPanel();
  261. if (CanRenderBars(currentState)) {
  262. RenderBars(currentState);
  263. // clear red dot next time button shows
  264. HotReloadState.ShowingRedDot = false;
  265. }
  266. }
  267. }
  268. // At the end to not fuck up rendering https://answers.unity.com/questions/400454/argumentexception-getting-control-0s-position-in-a-1.html
  269. var renderStart = !EditorCodePatcher.Running && !EditorCodePatcher.Starting && !currentState.requestingDownloadAndRun && currentState.redeemStage == RedeemStage.None;
  270. var e = Event.current;
  271. if (renderStart && e.type == EventType.KeyUp
  272. && (e.keyCode == KeyCode.Return
  273. || e.keyCode == KeyCode.KeypadEnter)
  274. ) {
  275. EditorCodePatcher.DownloadAndRun().Forget();
  276. }
  277. }
  278. internal static void RenderUpgradeLicenseNote(HotReloadRunTabState currentState, GUIStyle style) {
  279. var isIndie = RedeemLicenseHelper.I.RegistrationOutcome == RegistrationOutcome.Indie
  280. || EditorCodePatcher.licenseType == UnityLicenseType.UnityPersonalPlus;
  281. if (RedeemLicenseHelper.I.RegistrationOutcome == RegistrationOutcome.Business
  282. && currentState.loginStatus?.isBusinessLicense != true
  283. && EditorCodePatcher.Running
  284. && (PackageConst.IsAssetStoreBuild || HotReloadPrefs.RateAppShown)
  285. ) {
  286. // Warn asset store users they need to buy a business license
  287. // Website users get reminded after using Hot Reload for 5+ days
  288. RenderBusinessLicenseInfo(style);
  289. } else if (isIndie
  290. && HotReloadPrefs.RateAppShown
  291. && !PackageConst.IsAssetStoreBuild
  292. && EditorCodePatcher.Running
  293. && currentState.loginStatus?.isBusinessLicense != true
  294. && currentState.loginStatus?.isIndieLicense != true
  295. ) {
  296. // Reminder users they need to buy an indie license
  297. RenderIndieLicenseInfo(style);
  298. }
  299. }
  300. internal static bool CanRenderBars(HotReloadRunTabState currentState) {
  301. return HotReloadWindowStyles.windowScreenHeight > Constants.EventsListHideHeight
  302. && HotReloadWindowStyles.windowScreenWidth > Constants.EventsListHideWidth
  303. && !currentState.starting
  304. && !currentState.stopping
  305. && !currentState.requestingDownloadAndRun
  306. ;
  307. }
  308. static Texture2D GetFoldoutIcon(AlertEntry alertEntry) {
  309. InvertibleIcon alertIcon = InvertibleIcon.FoldoutClosed;
  310. if (HotReloadTimelineHelper.expandedEntries.Contains(alertEntry)) {
  311. alertIcon = InvertibleIcon.FoldoutOpen;
  312. }
  313. return GUIHelper.GetInvertibleIcon(alertIcon);
  314. }
  315. static void ToggleEntry(AlertEntry alertEntry) {
  316. if (HotReloadTimelineHelper.expandedEntries.Contains(alertEntry)) {
  317. HotReloadTimelineHelper.expandedEntries.Remove(alertEntry);
  318. } else {
  319. HotReloadTimelineHelper.expandedEntries.Add(alertEntry);
  320. }
  321. }
  322. static void RenderEntries(TimelineType timelineType) {
  323. List<AlertEntry> alertEntries;
  324. alertEntries = timelineType == TimelineType.Suggestions ? HotReloadTimelineHelper.Suggestions : HotReloadTimelineHelper.EventsTimeline;
  325. bool skipChildren = false;
  326. for (int i = 0; i < alertEntries.Count; i++) {
  327. var alertEntry = alertEntries[i];
  328. if (i > HotReloadTimelineHelper.maxVisibleEntries && alertEntry.entryType != EntryType.Child) {
  329. break;
  330. }
  331. if (timelineType != TimelineType.Suggestions) {
  332. if (alertEntry.entryType != EntryType.Child
  333. && !enabledFilters.Contains(alertEntry.alertType)
  334. ) {
  335. skipChildren = true;
  336. continue;
  337. } else if (alertEntry.entryType == EntryType.Child && skipChildren) {
  338. continue;
  339. } else {
  340. skipChildren = false;
  341. }
  342. }
  343. EntryType entryType = alertEntry.entryType;
  344. string title = $" {alertEntry.title}{(!string.IsNullOrEmpty(alertEntry.shortDescription) ? $": {alertEntry.shortDescription}": "")}";
  345. Texture2D icon = null;
  346. GUIStyle style;
  347. if (entryType != EntryType.Child) {
  348. icon = GUIHelper.GetLocalIcon(HotReloadTimelineHelper.alertIconString[alertEntry.iconType]);
  349. }
  350. if (entryType == EntryType.Child) {
  351. style = HotReloadWindowStyles.ChildBarStyle;
  352. } else if (entryType == EntryType.Foldout) {
  353. style = HotReloadWindowStyles.FoldoutBarStyle;
  354. } else {
  355. style = HotReloadWindowStyles.BarStyle;
  356. }
  357. Rect startRect;
  358. using (new EditorGUILayout.HorizontalScope()) {
  359. GUILayout.Space(0);
  360. Rect spaceRect = GUILayoutUtility.GetLastRect();
  361. // entry header foldout arrow
  362. if (entryType == EntryType.Foldout) {
  363. GUI.Label(new Rect(spaceRect.x + 3, spaceRect.y, 20, 20), new GUIContent(GetFoldoutIcon(alertEntry)));
  364. } else if (entryType == EntryType.Child) {
  365. GUI.Label(new Rect(spaceRect.x + 26, spaceRect.y + 2, 20, 20), new GUIContent(GetFoldoutIcon(alertEntry)));
  366. }
  367. // a workaround to limit the width of the label
  368. GUILayout.Label(new GUIContent(""), style);
  369. startRect = GUILayoutUtility.GetLastRect();
  370. GUI.Label(startRect, new GUIContent(title, icon), style);
  371. }
  372. bool clickableDescription = (alertEntry.title == "Unsupported change" || alertEntry.title == "Compile error" || alertEntry.title == "Failed applying patch to method") && alertEntry.alertData.alertEntryType != AlertEntryType.InlinedMethod;
  373. if (HotReloadTimelineHelper.expandedEntries.Contains(alertEntry) || alertEntry.alertType == AlertType.CompileError) {
  374. using (new EditorGUILayout.VerticalScope()) {
  375. using (new EditorGUILayout.HorizontalScope()) {
  376. using (new EditorGUILayout.VerticalScope(entryType == EntryType.Child ? HotReloadWindowStyles.ChildEntryBoxStyle : HotReloadWindowStyles.EntryBoxStyle)) {
  377. if (alertEntry.alertType == AlertType.Suggestion || !clickableDescription) {
  378. GUILayout.Label(alertEntry.description, HotReloadWindowStyles.LabelStyle);
  379. }
  380. if (alertEntry.actionData != null) {
  381. alertEntry.actionData.Invoke();
  382. }
  383. GUILayout.Space(5f);
  384. }
  385. }
  386. }
  387. }
  388. // remove button
  389. if (timelineType == TimelineType.Suggestions && alertEntry.hasExitButton) {
  390. var isClick = GUI.Button(new Rect(startRect.x + startRect.width - 20, startRect.y + 2, 20, 20), new GUIContent(GUIHelper.GetInvertibleIcon(InvertibleIcon.Close)), HotReloadWindowStyles.RemoveIconStyle);
  391. if (isClick) {
  392. HotReloadTimelineHelper.EventsTimeline.Remove(alertEntry);
  393. var kind = HotReloadSuggestionsHelper.FindSuggestionKind(alertEntry);
  394. if (kind != null) {
  395. HotReloadSuggestionsHelper.SetSuggestionInactive((HotReloadSuggestionKind)kind);
  396. }
  397. _instantRepaint = true;
  398. }
  399. }
  400. // Extend background to whole entry
  401. var endRect = GUILayoutUtility.GetLastRect();
  402. if (GUI.Button(new Rect(startRect) { height = endRect.y - startRect.y + endRect.height}, new GUIContent(""), HotReloadWindowStyles.BarBackgroundStyle) && (entryType == EntryType.Child || entryType == EntryType.Foldout)) {
  403. ToggleEntry(alertEntry);
  404. }
  405. if (alertEntry.alertType != AlertType.Suggestion && HotReloadWindowStyles.windowScreenWidth > 400 && entryType != EntryType.Child) {
  406. using (new EditorGUILayout.HorizontalScope()) {
  407. var ago = (DateTime.Now - alertEntry.timestamp);
  408. GUI.Label(new Rect(startRect.x + startRect.width - 60, startRect.y, 80, 20), ago.TotalMinutes < 1 ? "now" : $"{(ago.TotalHours > 1 ? $"{Math.Floor(ago.TotalHours)} h " : string.Empty)}{ago.Minutes} min", HotReloadWindowStyles.TimestampStyle);
  409. }
  410. }
  411. GUILayout.Space(1f);
  412. }
  413. if (timelineType != TimelineType.Suggestions && HotReloadTimelineHelper.GetRunTabTimelineEventCount() > 40) {
  414. GUILayout.Space(3f);
  415. GUILayout.Label(Constants.Only40EntriesShown, HotReloadWindowStyles.EmptyListText);
  416. }
  417. }
  418. private static List<AlertType> _enabledFilters;
  419. private static List<AlertType> enabledFilters {
  420. get {
  421. if (_enabledFilters == null) {
  422. _enabledFilters = new List<AlertType>();
  423. }
  424. if (HotReloadPrefs.RunTabUnsupportedChangesFilter && !_enabledFilters.Contains(AlertType.UnsupportedChange))
  425. _enabledFilters.Add(AlertType.UnsupportedChange);
  426. if (!HotReloadPrefs.RunTabUnsupportedChangesFilter && _enabledFilters.Contains(AlertType.UnsupportedChange))
  427. _enabledFilters.Remove(AlertType.UnsupportedChange);
  428. if (HotReloadPrefs.RunTabCompileErrorFilter && !_enabledFilters.Contains(AlertType.CompileError))
  429. _enabledFilters.Add(AlertType.CompileError);
  430. if (!HotReloadPrefs.RunTabCompileErrorFilter && _enabledFilters.Contains(AlertType.CompileError))
  431. _enabledFilters.Remove(AlertType.CompileError);
  432. if (HotReloadPrefs.RunTabPartiallyAppliedPatchesFilter && !_enabledFilters.Contains(AlertType.PartiallySupportedChange))
  433. _enabledFilters.Add(AlertType.PartiallySupportedChange);
  434. if (!HotReloadPrefs.RunTabPartiallyAppliedPatchesFilter && _enabledFilters.Contains(AlertType.PartiallySupportedChange))
  435. _enabledFilters.Remove(AlertType.PartiallySupportedChange);
  436. if (HotReloadPrefs.RunTabUndetectedPatchesFilter && !_enabledFilters.Contains(AlertType.UndetectedChange))
  437. _enabledFilters.Add(AlertType.UndetectedChange);
  438. if (!HotReloadPrefs.RunTabUndetectedPatchesFilter && _enabledFilters.Contains(AlertType.UndetectedChange))
  439. _enabledFilters.Remove(AlertType.UndetectedChange);
  440. if (HotReloadPrefs.RunTabAppliedPatchesFilter && !_enabledFilters.Contains(AlertType.AppliedChange))
  441. _enabledFilters.Add(AlertType.AppliedChange);
  442. if (!HotReloadPrefs.RunTabAppliedPatchesFilter && _enabledFilters.Contains(AlertType.AppliedChange))
  443. _enabledFilters.Remove(AlertType.AppliedChange);
  444. return _enabledFilters;
  445. }
  446. }
  447. private Vector2 suggestionsScroll;
  448. static GUILayoutOption[] timelineButtonOptions = new[] { GUILayout.Height(27), GUILayout.Width(100) };
  449. internal static void RenderBars(HotReloadRunTabState currentState) {
  450. if (currentState.suggestionCount > 0) {
  451. GUILayout.Space(5f);
  452. using (new EditorGUILayout.HorizontalScope(HotReloadWindowStyles.Section)) {
  453. using (new EditorGUILayout.VerticalScope()) {
  454. HotReloadPrefs.RunTabEventsSuggestionsFoldout = EditorGUILayout.Foldout(HotReloadPrefs.RunTabEventsSuggestionsFoldout, "", true, HotReloadWindowStyles.CustomFoldoutStyle);
  455. GUILayout.Space(-23);
  456. if (GUILayout.Button($"Suggestions ({currentState.suggestionCount.ToString()})", HotReloadWindowStyles.ClickableLabelBoldStyle, GUILayout.Height(27))) {
  457. HotReloadPrefs.RunTabEventsSuggestionsFoldout = !HotReloadPrefs.RunTabEventsSuggestionsFoldout;
  458. }
  459. if (HotReloadPrefs.RunTabEventsSuggestionsFoldout) {
  460. using (new EditorGUILayout.VerticalScope(HotReloadWindowStyles.Scroll)) {
  461. RenderEntries(TimelineType.Suggestions);
  462. }
  463. }
  464. }
  465. }
  466. }
  467. GUILayout.Space(5f);
  468. using (new EditorGUILayout.HorizontalScope(HotReloadWindowStyles.Section)) {
  469. using (new EditorGUILayout.VerticalScope()) {
  470. HotReloadPrefs.RunTabEventsTimelineFoldout = EditorGUILayout.Foldout(HotReloadPrefs.RunTabEventsTimelineFoldout, "", true, HotReloadWindowStyles.CustomFoldoutStyle);
  471. GUILayout.Space(-23);
  472. if (GUILayout.Button("Timeline", HotReloadWindowStyles.ClickableLabelBoldStyle, timelineButtonOptions)) {
  473. HotReloadPrefs.RunTabEventsTimelineFoldout = !HotReloadPrefs.RunTabEventsTimelineFoldout;
  474. }
  475. if (HotReloadPrefs.RunTabEventsTimelineFoldout) {
  476. GUILayout.Space(-10);
  477. var noteShown = HotReloadTimelineHelper.GetRunTabTimelineEventCount() == 0 || !currentState.running;
  478. using (new EditorGUILayout.HorizontalScope()) {
  479. if (noteShown) {
  480. GUILayout.Space(2f);
  481. using (new EditorGUILayout.VerticalScope()) {
  482. GUILayout.Space(2f);
  483. string text;
  484. if (currentState.redeemStage != RedeemStage.None) {
  485. text = "Complete registration before using Hot Reload";
  486. } else if (!currentState.running) {
  487. text = "Use the Start button to activate Hot Reload";
  488. } else if (enabledFilters.Count < 4 && HotReloadTimelineHelper.EventsTimeline.Count != 0) {
  489. text = "Enable filters to see events";
  490. } else {
  491. text = "Make code changes to see events";
  492. }
  493. GUILayout.Label(text, HotReloadWindowStyles.EmptyListText);
  494. }
  495. GUILayout.FlexibleSpace();
  496. } else {
  497. GUILayout.FlexibleSpace();
  498. if (HotReloadTimelineHelper.EventsTimeline.Count > 0 && GUILayout.Button("Clear")) {
  499. HotReloadTimelineHelper.ClearEntries();
  500. if (HotReloadWindow.Current) {
  501. HotReloadWindow.Current.Repaint();
  502. }
  503. }
  504. GUILayout.Space(3);
  505. }
  506. }
  507. if (!noteShown) {
  508. GUILayout.Space(2f);
  509. using (new EditorGUILayout.VerticalScope()) {
  510. RenderEntries(TimelineType.Timeline);
  511. }
  512. }
  513. }
  514. }
  515. }
  516. }
  517. internal static void RenderConsumption(LoginStatusResponse loginStatus) {
  518. if (loginStatus == null) {
  519. return;
  520. }
  521. EditorGUILayout.Space();
  522. EditorGUILayout.LabelField($"Hot Reload Limited", HotReloadWindowStyles.H3CenteredTitleStyle);
  523. EditorGUILayout.Space();
  524. if (loginStatus.consumptionsUnavailableReason == ConsumptionsUnavailableReason.NetworkUnreachable) {
  525. EditorGUILayout.HelpBox("Something went wrong. Please check your internet connection.", MessageType.Warning);
  526. } else if (loginStatus.consumptionsUnavailableReason == ConsumptionsUnavailableReason.UnrecoverableError) {
  527. EditorGUILayout.HelpBox("Something went wrong. Please contact support if the issue persists.", MessageType.Error);
  528. } else if (loginStatus.freeSessionFinished) {
  529. var now = DateTime.UtcNow;
  530. var sessionRefreshesAt = (now.AddDays(1).Date - now).Add(TimeSpan.FromMinutes(5));
  531. var sessionRefreshString = $"Next Session: {(sessionRefreshesAt.Hours > 0 ? $"{sessionRefreshesAt.Hours}h " : "")}{sessionRefreshesAt.Minutes}min";
  532. HotReloadGUIHelper.HelpBox(sessionRefreshString, MessageType.Warning, fontSize: 11);
  533. } else if (loginStatus.freeSessionRunning && loginStatus.freeSessionEndTime != null) {
  534. var sessionEndsAt = loginStatus.freeSessionEndTime.Value - DateTime.Now;
  535. var sessionString = $"Daily Session: {(sessionEndsAt.Hours > 0 ? $"{sessionEndsAt.Hours}h " : "")}{sessionEndsAt.Minutes}min Left";
  536. HotReloadGUIHelper.HelpBox(sessionString, MessageType.Info, fontSize: 11);
  537. } else if (loginStatus.freeSessionEndTime == null) {
  538. HotReloadGUIHelper.HelpBox("Daily Session: Make code changes to start", MessageType.Info, fontSize: 11);
  539. }
  540. }
  541. static bool _repaint;
  542. static bool _instantRepaint;
  543. static DateTime _lastRepaint;
  544. private EditorIndicationState.IndicationStatus _lastStatus;
  545. public override void Update() {
  546. if (EditorIndicationState.SpinnerActive) {
  547. _repaint = true;
  548. }
  549. if (EditorCodePatcher.DownloadRequired) {
  550. _repaint = true;
  551. }
  552. if (EditorIndicationState.IndicationIconPath == Spinner.SpinnerIconPath) {
  553. _repaint = true;
  554. }
  555. try {
  556. // workaround: hovering over non-buttons doesn't repain by default
  557. if (EditorWindow.mouseOverWindow == HotReloadWindow.Current) {
  558. _repaint = true;
  559. }
  560. if (EditorWindow.mouseOverWindow
  561. && EditorWindow.mouseOverWindow?.GetType() == typeof(PopupWindow)
  562. && HotReloadEventPopup.I.open
  563. ) {
  564. _repaint = true;
  565. }
  566. } catch (NullReferenceException) {
  567. // Unity randomly throws nullrefs when EditorWindow.mouseOverWindow gets accessed
  568. }
  569. if (_repaint && DateTime.UtcNow - _lastRepaint > TimeSpan.FromMilliseconds(33)) {
  570. _repaint = false;
  571. _instantRepaint = true;
  572. }
  573. // repaint on status change
  574. var status = EditorIndicationState.CurrentIndicationStatus;
  575. if (_lastStatus != status) {
  576. _lastStatus = status;
  577. _instantRepaint = true;
  578. }
  579. if (_instantRepaint) {
  580. Repaint();
  581. HotReloadEventPopup.I.Repaint();
  582. _instantRepaint = false;
  583. _repaint = false;
  584. _lastRepaint = DateTime.UtcNow;
  585. }
  586. }
  587. public static void RepaintInstant() {
  588. _instantRepaint = true;
  589. }
  590. private void RenderRecompileButton() {
  591. string recompileText = HotReloadWindowStyles.windowScreenWidth > Constants.RecompileButtonTextHideWidth ? " Recompile" : "";
  592. var recompileButton = new GUIContent(recompileText, GUIHelper.GetInvertibleIcon(InvertibleIcon.Recompile));
  593. if (!GUILayout.Button(recompileButton, HotReloadWindowStyles.RecompileButton)) {
  594. return;
  595. }
  596. RecompileWithChecks();
  597. }
  598. public static void RecompileWithChecks() {
  599. var firstDialoguePass = HotReloadPrefs.RecompileDialogueShown
  600. || EditorUtility.DisplayDialog(
  601. title: "Hot Reload auto-applies changes",
  602. message: "Using the Recompile button is only necessary when Hot Reload fails to apply your changes. \n\nDo you wish to proceed?",
  603. ok: "Recompile",
  604. cancel: "Not now");
  605. HotReloadPrefs.RecompileDialogueShown = true;
  606. if (!firstDialoguePass) {
  607. return;
  608. }
  609. if (!ConfirmExitPlaymode("Using the Recompile button will stop Play Mode.\n\nDo you wish to proceed?")) {
  610. return;
  611. }
  612. Recompile();
  613. }
  614. #if UNITY_2020_1_OR_NEWER
  615. public static void SwitchToDebugMode() {
  616. CompilationPipeline.codeOptimization = CodeOptimization.Debug;
  617. HotReloadRunTab.Recompile();
  618. HotReloadSuggestionsHelper.SetSuggestionInactive(HotReloadSuggestionKind.SwitchToDebugModeForInlinedMethods);
  619. }
  620. #endif
  621. public static bool ConfirmExitPlaymode(string message) {
  622. return !Application.isPlaying
  623. || EditorUtility.DisplayDialog(
  624. title: "Stop Play Mode and Recompile?",
  625. message: message,
  626. ok: "Stop and Recompile",
  627. cancel: "Cancel");
  628. }
  629. public static bool recompiling;
  630. public static void Recompile() {
  631. recompiling = true;
  632. EditorApplication.isPlaying = false;
  633. CompileMethodDetourer.Reset();
  634. AssetDatabase.Refresh();
  635. // This forces the recompilation if no changes were made.
  636. // This is better UX because otherwise the recompile button is unresponsive
  637. // which can be extra annoying if there are compile error entries in the list
  638. if (!EditorApplication.isCompiling) {
  639. CompilationPipeline.RequestScriptCompilation();
  640. }
  641. }
  642. private void RenderIndicationButtons() {
  643. if (currentState.requestingDownloadAndRun || currentState.starting || currentState.stopping || currentState.redeemStage != RedeemStage.None) {
  644. return;
  645. }
  646. if (!currentState.running && (currentState.startupProgress?.Item1 ?? 0) == 0) {
  647. string startText = HotReloadWindowStyles.windowScreenWidth > Constants.StartButtonTextHideWidth ? " Start" : "";
  648. if (GUILayout.Button(new GUIContent(startText, GUIHelper.GetInvertibleIcon(InvertibleIcon.Start)), HotReloadWindowStyles.StartButton)) {
  649. EditorCodePatcher.DownloadAndRun().Forget();
  650. }
  651. } else if (currentState.running && !currentState.starting) {
  652. if (HotReloadWindowStyles.windowScreenWidth > 150) {
  653. RenderRecompileButton();
  654. }
  655. string stopText = HotReloadWindowStyles.windowScreenWidth > Constants.StartButtonTextHideWidth ? " Stop" : "";
  656. if (GUILayout.Button(new GUIContent(stopText, GUIHelper.GetInvertibleIcon(InvertibleIcon.Stop)), HotReloadWindowStyles.StopButton)) {
  657. if (!EditorCodePatcher.StoppedServerRecently()) {
  658. EditorCodePatcher.StopCodePatcher().Forget();
  659. }
  660. }
  661. }
  662. }
  663. void RenderIndicationPanel() {
  664. using (new EditorGUILayout.HorizontalScope(HotReloadWindowStyles.SectionInnerBox)) {
  665. RenderIndication();
  666. if (HotReloadWindowStyles.windowScreenWidth > Constants.IndicationTextHideWidth) {
  667. GUILayout.FlexibleSpace();
  668. }
  669. RenderIndicationButtons();
  670. if (HotReloadWindowStyles.windowScreenWidth <= Constants.IndicationTextHideWidth) {
  671. GUILayout.FlexibleSpace();
  672. }
  673. }
  674. if (currentState.requestingDownloadAndRun || currentState.starting) {
  675. RenderProgressBar();
  676. }
  677. if (HotReloadWindowStyles.windowScreenWidth > Constants.ConsumptionsHideWidth
  678. && HotReloadWindowStyles.windowScreenHeight > Constants.ConsumptionsHideHeight
  679. ) {
  680. RenderLicenseInfo(currentState);
  681. }
  682. }
  683. internal static void RenderLicenseInfo(HotReloadRunTabState currentState) {
  684. var showRedeem = currentState.redeemStage != RedeemStage.None;
  685. var showConsumptions = ShouldRenderConsumption(currentState);
  686. if (!showConsumptions && !showRedeem) {
  687. return;
  688. }
  689. using (new EditorGUILayout.VerticalScope()) {
  690. // space needed only for consumptions because of Stop/Start button's margin
  691. if (showConsumptions) {
  692. GUILayout.Space(6);
  693. }
  694. using (new EditorGUILayout.VerticalScope(HotReloadWindowStyles.Section)) {
  695. if (showRedeem) {
  696. RedeemLicenseHelper.I.RenderStage(currentState);
  697. } else {
  698. RenderConsumption(currentState.loginStatus);
  699. GUILayout.Space(10);
  700. RenderLicenseInfo(currentState, currentState.loginStatus);
  701. RenderLicenseButtons(currentState);
  702. GUILayout.Space(10);
  703. }
  704. }
  705. GUILayout.Space(6);
  706. }
  707. }
  708. private Spinner _spinner = new Spinner(85);
  709. private void RenderIndication() {
  710. using (new EditorGUILayout.HorizontalScope(HotReloadWindowStyles.IndicationBox)) {
  711. // icon box
  712. if (HotReloadWindowStyles.windowScreenWidth <= Constants.IndicationTextHideWidth) {
  713. GUILayout.FlexibleSpace();
  714. }
  715. using (new EditorGUILayout.HorizontalScope(HotReloadWindowStyles.IndicationHelpBox)) {
  716. var text = HotReloadWindowStyles.windowScreenWidth > Constants.IndicationTextHideWidth ? $" {currentState.indicationStatusText}" : "";
  717. if (currentState.indicationIconPath == Spinner.SpinnerIconPath) {
  718. GUILayout.Label(new GUIContent(text, _spinner.GetIcon()), style: HotReloadWindowStyles.IndicationIcon);
  719. } else if (currentState.indicationIconPath != null) {
  720. var style = HotReloadWindowStyles.IndicationIcon;
  721. if (HotReloadTimelineHelper.alertIconString.ContainsValue(currentState.indicationIconPath)) {
  722. style = HotReloadWindowStyles.IndicationAlertIcon;
  723. }
  724. GUILayout.Label(new GUIContent(text, GUIHelper.GetLocalIcon(currentState.indicationIconPath)), style);
  725. }
  726. }
  727. }
  728. }
  729. static GUIStyle _openSettingsStyle;
  730. static GUIStyle openSettingsStyle => _openSettingsStyle ?? (_openSettingsStyle = new GUIStyle(GUI.skin.button) {
  731. fontStyle = FontStyle.Normal,
  732. fixedHeight = 25,
  733. });
  734. static GUILayoutOption[] _bigButtonHeight;
  735. public static GUILayoutOption[] bigButtonHeight => _bigButtonHeight ?? (_bigButtonHeight = new [] {GUILayout.Height(25)});
  736. private static GUIContent indieLicenseContent;
  737. private static GUIContent businessLicenseContent;
  738. internal static void RenderLicenseStatusInfo(HotReloadRunTabState currentState, LoginStatusResponse loginStatus, bool allowHide = true, bool verbose = false) {
  739. string message = null;
  740. MessageType messageType = default(MessageType);
  741. Action customGUI = null;
  742. GUIContent content = null;
  743. if (loginStatus == null) {
  744. // no info
  745. } else if (loginStatus.lastLicenseError != null) {
  746. messageType = !loginStatus.freeSessionFinished ? MessageType.Warning : MessageType.Error;
  747. message = GetMessageFromError(currentState, loginStatus.lastLicenseError);
  748. } else if (loginStatus.isTrial && !PackageConst.IsAssetStoreBuild) {
  749. message = $"Using Trial license, valid until {loginStatus.licenseExpiresAt.ToShortDateString()}";
  750. messageType = MessageType.Info;
  751. } else if (loginStatus.isIndieLicense) {
  752. if (verbose) {
  753. message = " Indie license active";
  754. messageType = MessageType.Info;
  755. customGUI = () => {
  756. if (loginStatus.licenseExpiresAt.Date != DateTime.MaxValue.Date) {
  757. EditorGUILayout.LabelField($"License will renew on {loginStatus.licenseExpiresAt.ToShortDateString()}.");
  758. EditorGUILayout.Space();
  759. }
  760. using (new GUILayout.HorizontalScope()) {
  761. HotReloadAboutTab.manageLicenseButton.OnGUI();
  762. HotReloadAboutTab.manageAccountButton.OnGUI();
  763. }
  764. EditorGUILayout.Space();
  765. };
  766. if (indieLicenseContent == null) {
  767. indieLicenseContent = new GUIContent(message, EditorGUIUtility.FindTexture("TestPassed"));
  768. }
  769. content = indieLicenseContent;
  770. }
  771. } else if (loginStatus.isBusinessLicense) {
  772. if (verbose) {
  773. message = " Business license active";
  774. messageType = MessageType.Info;
  775. if (businessLicenseContent == null) {
  776. businessLicenseContent = new GUIContent(message, EditorGUIUtility.FindTexture("TestPassed"));
  777. }
  778. content = businessLicenseContent;
  779. customGUI = () => {
  780. using (new GUILayout.HorizontalScope()) {
  781. HotReloadAboutTab.manageLicenseButton.OnGUI();
  782. HotReloadAboutTab.manageAccountButton.OnGUI();
  783. }
  784. EditorGUILayout.Space();
  785. };
  786. }
  787. }
  788. if (messageType != MessageType.Info && HotReloadPrefs.ErrorHidden && allowHide) {
  789. return;
  790. }
  791. if (message != null) {
  792. if (messageType != MessageType.Info) {
  793. using(new EditorGUILayout.HorizontalScope()) {
  794. EditorGUILayout.HelpBox(message, messageType);
  795. var style = HotReloadWindowStyles.HideButtonStyle;
  796. if (Event.current.type == EventType.Repaint) {
  797. style.fixedHeight = GUILayoutUtility.GetLastRect().height;
  798. }
  799. if (allowHide) {
  800. if (GUILayout.Button("Hide", style)) {
  801. HotReloadPrefs.ErrorHidden = true;
  802. }
  803. }
  804. }
  805. } else if (content != null) {
  806. EditorGUILayout.LabelField(content);
  807. EditorGUILayout.Space();
  808. } else {
  809. EditorGUILayout.LabelField(message);
  810. EditorGUILayout.Space();
  811. }
  812. customGUI?.Invoke();
  813. }
  814. }
  815. const string assetStoreProInfo = "Unity Pro/Enterprise users from company with your number of employees require a Business license. Please upgrade your license on our website.";
  816. internal static void RenderBusinessLicenseInfo(GUIStyle style) {
  817. GUILayout.Space(8);
  818. using (new EditorGUILayout.HorizontalScope()) {
  819. EditorGUILayout.HelpBox(assetStoreProInfo, MessageType.Info);
  820. if (Event.current.type == EventType.Repaint) {
  821. style.fixedHeight = GUILayoutUtility.GetLastRect().height;
  822. }
  823. if (GUILayout.Button("Upgrade", style)) {
  824. Application.OpenURL(Constants.ProductPurchaseBusinessURL);
  825. }
  826. }
  827. }
  828. internal static void RenderIndieLicenseInfo(GUIStyle style) {
  829. string message = "Unity Plus users require an Indie license. Please upgrade your license on our website.";
  830. GUILayout.Space(8);
  831. using (new EditorGUILayout.HorizontalScope()) {
  832. EditorGUILayout.HelpBox(message, MessageType.Info);
  833. if (Event.current.type == EventType.Repaint) {
  834. style.fixedHeight = GUILayoutUtility.GetLastRect().height;
  835. }
  836. if (GUILayout.Button("Upgrade", style)) {
  837. Application.OpenURL(Constants.ProductPurchaseURL);
  838. }
  839. }
  840. }
  841. const string GetLicense = "Get License";
  842. const string ContactSupport = "Contact Support";
  843. const string UpgradeLicense = "Upgrade License";
  844. const string ManageLicense = "Manage License";
  845. internal static Dictionary<string, LicenseErrorData> _licenseErrorData;
  846. internal static Dictionary<string, LicenseErrorData> LicenseErrorData => _licenseErrorData ?? (_licenseErrorData = new Dictionary<string, LicenseErrorData> {
  847. { "DeviceNotLicensedException", new LicenseErrorData(description: "Another device is using your license. Please reach out to customer support for assistance.", showSupportButton: true, supportButtonText: ContactSupport) },
  848. { "DeviceBlacklistedException", new LicenseErrorData(description: "You device has been blacklisted.") },
  849. { "DateHeaderInvalidException", new LicenseErrorData(description: $"Your license is not working because your computer's clock is incorrect. Please set the clock to the correct time to restore your license.") },
  850. { "DateTimeCheatingException", new LicenseErrorData(description: $"Your license is not working because your computer's clock is incorrect. Please set the clock to the correct time to restore your license.") },
  851. { "LicenseActivationException", new LicenseErrorData(description: "An error has occured while activating your license. Please contact customer support for assistance.", showSupportButton: true, supportButtonText: ContactSupport) },
  852. { "LicenseDeletedException", new LicenseErrorData(description: $"Your license has been deleted. Please contact customer support for assistance.", showBuyButton: true, buyButtonText: GetLicense, showSupportButton: true, supportButtonText: ContactSupport) },
  853. { "LicenseDisabledException", new LicenseErrorData(description: $"Your license has been disabled. Please contact customer support for assistance.", showBuyButton: true, buyButtonText: GetLicense, showSupportButton: true, supportButtonText: ContactSupport) },
  854. { "LicenseExpiredException", new LicenseErrorData(description: $"Your license has expired. Please renew your license subscription using the 'Upgrade License' button below and login with your email/password to activate your license.", showBuyButton: true, buyButtonText: UpgradeLicense, showManageLicenseButton: true, manageLicenseButtonText: ManageLicense) },
  855. { "LicenseInactiveException", new LicenseErrorData(description: $"Your license is currenty inactive. Please login with your email/password to activate your license.") },
  856. { "LocalLicenseException", new LicenseErrorData(description: $"Your license file was damaged or corrupted. Please login with your email/password to refresh your license file.") },
  857. // Note: obsolete
  858. { "MissingParametersException", new LicenseErrorData(description: "An account already exists for this device. Please login with your existing email/password.", showBuyButton: true, buyButtonText: GetLicense) },
  859. { "NetworkException", new LicenseErrorData(description: "There is an issue connecting to our servers. Please check your internet connection or contact customer support if the issue persists.", showSupportButton: true, supportButtonText: ContactSupport) },
  860. { "TrialLicenseExpiredException", new LicenseErrorData(description: $"Your trial has expired. Activate a license with unlimited usage or continue using the Free version. View available plans on our website.", showBuyButton: true, buyButtonText: UpgradeLicense) },
  861. { "InvalidCredentialException", new LicenseErrorData(description: "Incorrect email/password. You can find your initial password in the sign-up email.") },
  862. // Note: activating free trial with email is not supported anymore. This error shouldn't happen which is why we should rather user the fallback
  863. // { "LicenseNotFoundException", new LicenseErrorData(description: "The account you're trying to access doesn't seem to exist yet. Please enter your email address to create a new account and receive a trial license.", showLoginButton: true, loginButtonText: CreateAccount) },
  864. { "LicenseIncompatibleException", new LicenseErrorData(description: "Please upgrade your license to continue using hotreload with Unity Pro.", showManageLicenseButton: true, manageLicenseButtonText: ManageLicense) },
  865. });
  866. internal static LicenseErrorData defaultLicenseErrorData = new LicenseErrorData(description: "We apologize, an error happened while verifying your license. Please reach out to customer support for assistance.", showSupportButton: true, supportButtonText: ContactSupport);
  867. internal static string GetMessageFromError(HotReloadRunTabState currentState, string error) {
  868. if (PackageConst.IsAssetStoreBuild && error == "TrialLicenseExpiredException") {
  869. return assetStoreProInfo;
  870. }
  871. return GetLicenseErrorDataOrDefault(currentState, error).description;
  872. }
  873. internal static LicenseErrorData GetLicenseErrorDataOrDefault(HotReloadRunTabState currentState, string error) {
  874. if (currentState.loginStatus?.isFree == true) {
  875. return default(LicenseErrorData);
  876. }
  877. if (currentState.loginStatus == null || string.IsNullOrEmpty(error) && (!currentState.loginStatus.isLicensed || currentState.loginStatus.isTrial)) {
  878. return new LicenseErrorData(null, showBuyButton: true, buyButtonText: GetLicense);
  879. }
  880. if (string.IsNullOrEmpty(error)) {
  881. return default(LicenseErrorData);
  882. }
  883. if (!LicenseErrorData.ContainsKey(error)) {
  884. return defaultLicenseErrorData;
  885. }
  886. return LicenseErrorData[error];
  887. }
  888. internal static void RenderBuyLicenseButton(string buyLicenseButton) {
  889. OpenURLButton.Render(buyLicenseButton, Constants.ProductPurchaseURL);
  890. }
  891. static void RenderLicenseActionButtons(HotReloadRunTabState currentState) {
  892. var errInfo = GetLicenseErrorDataOrDefault(currentState, currentState.loginStatus?.lastLicenseError);
  893. if (errInfo.showBuyButton || errInfo.showManageLicenseButton) {
  894. using(new EditorGUILayout.HorizontalScope()) {
  895. if (errInfo.showBuyButton) {
  896. RenderBuyLicenseButton(errInfo.buyButtonText);
  897. }
  898. if (errInfo.showManageLicenseButton && !HotReloadPrefs.ErrorHidden) {
  899. OpenURLButton.Render(errInfo.manageLicenseButtonText, Constants.ManageLicenseURL);
  900. }
  901. }
  902. }
  903. if (errInfo.showLoginButton && GUILayout.Button(errInfo.loginButtonText, openSettingsStyle)) {
  904. // show license section
  905. HotReloadWindow.Current.SelectTab(typeof(HotReloadSettingsTab));
  906. HotReloadWindow.Current.SettingsTab.FocusLicenseFoldout();
  907. }
  908. if (errInfo.showSupportButton && !HotReloadPrefs.ErrorHidden) {
  909. OpenURLButton.Render(errInfo.supportButtonText, Constants.ContactURL);
  910. }
  911. if (currentState.loginStatus?.lastLicenseError != null) {
  912. HotReloadAboutTab.reportIssueButton.OnGUI();
  913. }
  914. }
  915. internal static void RenderLicenseInfo(HotReloadRunTabState currentState, LoginStatusResponse loginStatus, bool verbose = false, bool allowHide = true, string overrideActionButton = null, bool showConsumptions = false) {
  916. HotReloadPrefs.ShowLogin = EditorGUILayout.Foldout(HotReloadPrefs.ShowLogin, "Hot Reload License", true, HotReloadWindowStyles.FoldoutStyle);
  917. if (HotReloadPrefs.ShowLogin) {
  918. EditorGUILayout.Space();
  919. if ((loginStatus?.isLicensed != true && showConsumptions) && !(loginStatus == null || loginStatus.isFree)) {
  920. RenderConsumption(loginStatus);
  921. }
  922. RenderLicenseStatusInfo(currentState, loginStatus: loginStatus, allowHide: allowHide, verbose: verbose);
  923. RenderLicenseInnerPanel(currentState, overrideActionButton: overrideActionButton);
  924. EditorGUILayout.Space();
  925. EditorGUILayout.Space();
  926. }
  927. }
  928. internal void RenderPromoCodes() {
  929. HotReloadPrefs.ShowPromoCodes = EditorGUILayout.Foldout(HotReloadPrefs.ShowPromoCodes, "Promo Codes", true, HotReloadWindowStyles.FoldoutStyle);
  930. if (!HotReloadPrefs.ShowPromoCodes) {
  931. return;
  932. }
  933. if (promoCodeActivatedThisSession) {
  934. EditorGUILayout.HelpBox($"Your promo code has been successfully activated. Free trial has been extended by 3 months.", MessageType.Info);
  935. } else {
  936. if (promoCodeError != null && promoCodeErrorType != MessageType.None) {
  937. EditorGUILayout.HelpBox(promoCodeError, promoCodeErrorType);
  938. }
  939. EditorGUILayout.LabelField("Promo code");
  940. _pendingPromoCode = EditorGUILayout.TextField(_pendingPromoCode);
  941. EditorGUILayout.Space();
  942. using (new EditorGUI.DisabledScope(_requestingActivatePromoCode)) {
  943. if (GUILayout.Button("Activate promo code", HotReloadRunTab.bigButtonHeight)) {
  944. RequestActivatePromoCode().Forget();
  945. }
  946. }
  947. }
  948. EditorGUILayout.Space();
  949. EditorGUILayout.Space();
  950. }
  951. private async Task RequestActivatePromoCode() {
  952. _requestingActivatePromoCode = true;
  953. try {
  954. var resp = await RequestHelper.RequestActivatePromoCode(_pendingPromoCode);
  955. if (resp != null && resp.error == null) {
  956. promoCodeActivatedThisSession = true;
  957. } else {
  958. var requestError = resp?.error ?? "Network error";
  959. var errorType = ToErrorType(requestError);
  960. promoCodeError = ToPrettyErrorMessage(errorType);
  961. promoCodeErrorType = ToMessageType(errorType);
  962. }
  963. } finally {
  964. _requestingActivatePromoCode = false;
  965. }
  966. }
  967. PromoCodeErrorType ToErrorType(string error) {
  968. switch (error) {
  969. case "Input is missing": return PromoCodeErrorType.MISSING_INPUT;
  970. case "only POST is supported": return PromoCodeErrorType.INVALID_HTTP_METHOD;
  971. case "body is not a valid json": return PromoCodeErrorType.BODY_INVALID;
  972. case "Promo code is not found": return PromoCodeErrorType.PROMO_CODE_NOT_FOUND;
  973. case "Promo code already claimed": return PromoCodeErrorType.PROMO_CODE_CLAIMED;
  974. case "Promo code expired": return PromoCodeErrorType.PROMO_CODE_EXPIRED;
  975. case "License not found": return PromoCodeErrorType.LICENSE_NOT_FOUND;
  976. case "License is not a trial": return PromoCodeErrorType.LICENSE_NOT_TRIAL;
  977. case "License already extended": return PromoCodeErrorType.LICENSE_ALREADY_EXTENDED;
  978. case "conditionalCheckFailed": return PromoCodeErrorType.CONDITIONAL_CHECK_FAILED;
  979. }
  980. if (error.Contains("Updating License Failed with error")) {
  981. return PromoCodeErrorType.UPDATING_LICENSE_FAILED;
  982. } else if (error.Contains("Unknown exception")) {
  983. return PromoCodeErrorType.UNKNOWN_EXCEPTION;
  984. } else if (error.Contains("Unsupported path")) {
  985. return PromoCodeErrorType.UNSUPPORTED_PATH;
  986. }
  987. return PromoCodeErrorType.NONE;
  988. }
  989. string ToPrettyErrorMessage(PromoCodeErrorType errorType) {
  990. var defaultMsg = "We apologize, an error happened while activating your promo code. Please reach out to customer support for assistance.";
  991. switch (errorType) {
  992. case PromoCodeErrorType.MISSING_INPUT:
  993. case PromoCodeErrorType.INVALID_HTTP_METHOD:
  994. case PromoCodeErrorType.BODY_INVALID:
  995. case PromoCodeErrorType.UNKNOWN_EXCEPTION:
  996. case PromoCodeErrorType.UNSUPPORTED_PATH:
  997. case PromoCodeErrorType.LICENSE_NOT_FOUND:
  998. case PromoCodeErrorType.UPDATING_LICENSE_FAILED:
  999. case PromoCodeErrorType.LICENSE_NOT_TRIAL:
  1000. return defaultMsg;
  1001. case PromoCodeErrorType.PROMO_CODE_NOT_FOUND: return "Your promo code is invalid. Please ensure that you have entered the correct promo code.";
  1002. case PromoCodeErrorType.PROMO_CODE_CLAIMED: return "Your promo code has already been used.";
  1003. case PromoCodeErrorType.PROMO_CODE_EXPIRED: return "Your promo code has expired.";
  1004. case PromoCodeErrorType.LICENSE_ALREADY_EXTENDED: return "Your license has already been activated with a promo code. Only one promo code activation per license is allowed.";
  1005. case PromoCodeErrorType.CONDITIONAL_CHECK_FAILED: return "We encountered an error while activating your promo code. Please try again. If the issue persists, please contact our customer support team for assistance.";
  1006. case PromoCodeErrorType.NONE: return "There is an issue connecting to our servers. Please check your internet connection or contact customer support if the issue persists.";
  1007. default: return defaultMsg;
  1008. }
  1009. }
  1010. MessageType ToMessageType(PromoCodeErrorType errorType) {
  1011. switch (errorType) {
  1012. case PromoCodeErrorType.MISSING_INPUT: return MessageType.Error;
  1013. case PromoCodeErrorType.INVALID_HTTP_METHOD: return MessageType.Error;
  1014. case PromoCodeErrorType.BODY_INVALID: return MessageType.Error;
  1015. case PromoCodeErrorType.PROMO_CODE_NOT_FOUND: return MessageType.Warning;
  1016. case PromoCodeErrorType.PROMO_CODE_CLAIMED: return MessageType.Warning;
  1017. case PromoCodeErrorType.PROMO_CODE_EXPIRED: return MessageType.Warning;
  1018. case PromoCodeErrorType.LICENSE_NOT_FOUND: return MessageType.Error;
  1019. case PromoCodeErrorType.LICENSE_NOT_TRIAL: return MessageType.Error;
  1020. case PromoCodeErrorType.LICENSE_ALREADY_EXTENDED: return MessageType.Warning;
  1021. case PromoCodeErrorType.UPDATING_LICENSE_FAILED: return MessageType.Error;
  1022. case PromoCodeErrorType.CONDITIONAL_CHECK_FAILED: return MessageType.Error;
  1023. case PromoCodeErrorType.UNKNOWN_EXCEPTION: return MessageType.Error;
  1024. case PromoCodeErrorType.UNSUPPORTED_PATH: return MessageType.Error;
  1025. case PromoCodeErrorType.NONE: return MessageType.Error;
  1026. default: return MessageType.Error;
  1027. }
  1028. }
  1029. public static void RenderLicenseButtons(HotReloadRunTabState currentState) {
  1030. RenderLicenseActionButtons(currentState);
  1031. }
  1032. internal static void RenderLicenseInnerPanel(HotReloadRunTabState currentState, string overrideActionButton = null, bool renderLogout = true) {
  1033. EditorGUILayout.LabelField("Email");
  1034. GUI.SetNextControlName("email");
  1035. _pendingEmail = EditorGUILayout.TextField(string.IsNullOrEmpty(_pendingEmail) ? HotReloadPrefs.LicenseEmail : _pendingEmail);
  1036. _pendingEmail = _pendingEmail.Trim();
  1037. EditorGUILayout.LabelField("Password");
  1038. GUI.SetNextControlName("password");
  1039. _pendingPassword = EditorGUILayout.PasswordField(string.IsNullOrEmpty(_pendingPassword) ? HotReloadPrefs.LicensePassword : _pendingPassword);
  1040. RenderSwitchAuthMode();
  1041. var e = Event.current;
  1042. using(new EditorGUI.DisabledScope(currentState.requestingLoginInfo)) {
  1043. var btnLabel = overrideActionButton;
  1044. if (String.IsNullOrEmpty(overrideActionButton)) {
  1045. btnLabel = "Login";
  1046. }
  1047. using (new EditorGUILayout.HorizontalScope()) {
  1048. var focusedControl = GUI.GetNameOfFocusedControl();
  1049. if (GUILayout.Button(btnLabel, bigButtonHeight)
  1050. || (focusedControl == "email"
  1051. || focusedControl == "password")
  1052. && e.type == EventType.KeyUp
  1053. && (e.keyCode == KeyCode.Return
  1054. || e.keyCode == KeyCode.KeypadEnter)
  1055. ) {
  1056. var error = ValidateEmail(_pendingEmail);
  1057. if (!string.IsNullOrEmpty(error)) {
  1058. _activateInfoMessage = new Tuple<string, MessageType>(error, MessageType.Warning);
  1059. } else if (string.IsNullOrEmpty(_pendingPassword)) {
  1060. _activateInfoMessage = new Tuple<string, MessageType>("Please enter your password.", MessageType.Warning);
  1061. } else {
  1062. HotReloadWindow.Current.SelectTab(typeof(HotReloadRunTab));
  1063. _activateInfoMessage = null;
  1064. if (RedeemLicenseHelper.I.RedeemStage == RedeemStage.Login) {
  1065. RedeemLicenseHelper.I.FinishRegistration(RegistrationOutcome.Indie);
  1066. }
  1067. if (!EditorCodePatcher.RequestingDownloadAndRun && !EditorCodePatcher.Running) {
  1068. LoginOnDownloadAndRun(new LoginData(email: _pendingEmail, password: _pendingPassword)).Forget();
  1069. } else {
  1070. EditorCodePatcher.RequestLogin(_pendingEmail, _pendingPassword).Forget();
  1071. }
  1072. }
  1073. }
  1074. if (renderLogout) {
  1075. RenderLogout(currentState);
  1076. }
  1077. }
  1078. }
  1079. if (_activateInfoMessage != null && (e.type == EventType.Layout || e.type == EventType.Repaint)) {
  1080. EditorGUILayout.HelpBox(_activateInfoMessage.Item1, _activateInfoMessage.Item2);
  1081. }
  1082. }
  1083. public static string ValidateEmail(string email) {
  1084. if (string.IsNullOrEmpty(email)) {
  1085. return "Please enter your email address.";
  1086. } else if (!EditorWindowHelper.IsValidEmailAddress(email)) {
  1087. return "Please enter a valid email address.";
  1088. } else if (email.Contains("+")) {
  1089. return "Mail extensions (in a form of 'username+suffix@example.com') are not supported yet. Please provide your original email address (such as 'username@example.com' without '+suffix' part) as we're working on resolving this issue.";
  1090. }
  1091. return null;
  1092. }
  1093. public static void RenderLogout(HotReloadRunTabState currentState) {
  1094. if (currentState.loginStatus?.isLicensed != true) {
  1095. return;
  1096. }
  1097. if (GUILayout.Button("Logout", bigButtonHeight)) {
  1098. HotReloadWindow.Current.SelectTab(typeof(HotReloadRunTab));
  1099. if (!EditorCodePatcher.RequestingDownloadAndRun && !EditorCodePatcher.Running) {
  1100. LogoutOnDownloadAndRun().Forget();
  1101. } else {
  1102. RequestLogout().Forget();
  1103. }
  1104. }
  1105. }
  1106. async static Task LoginOnDownloadAndRun(LoginData loginData = null) {
  1107. var ok = await EditorCodePatcher.DownloadAndRun(loginData);
  1108. if (ok && loginData != null) {
  1109. HotReloadPrefs.ErrorHidden = false;
  1110. HotReloadPrefs.LicenseEmail = loginData.email;
  1111. HotReloadPrefs.LicensePassword = loginData.password;
  1112. }
  1113. }
  1114. async static Task LogoutOnDownloadAndRun() {
  1115. var ok = await EditorCodePatcher.DownloadAndRun();
  1116. if (!ok) {
  1117. return;
  1118. }
  1119. await RequestLogout();
  1120. }
  1121. private async static Task RequestLogout() {
  1122. int i = 0;
  1123. while (!EditorCodePatcher.Running && i < 100) {
  1124. await Task.Delay(100);
  1125. i++;
  1126. }
  1127. var resp = await RequestHelper.RequestLogout();
  1128. if (!EditorCodePatcher.RequestingLoginInfo && resp != null) {
  1129. EditorCodePatcher.HandleStatus(resp);
  1130. }
  1131. }
  1132. private static void RenderSwitchAuthMode() {
  1133. var color = EditorGUIUtility.isProSkin ? new Color32(0x3F, 0x9F, 0xFF, 0xFF) : new Color32(0x0F, 0x52, 0xD7, 0xFF);
  1134. if (HotReloadGUIHelper.LinkLabel("Forgot password?", 12, FontStyle.Normal, TextAnchor.MiddleLeft, color)) {
  1135. if (EditorUtility.DisplayDialog("Recover password", "Use company code 'naughtycult' and the email you signed up with in order to recover your account.", "Open in browser", "Cancel")) {
  1136. Application.OpenURL(Constants.ForgotPasswordURL);
  1137. }
  1138. }
  1139. }
  1140. Texture2D _greenTextureLight;
  1141. Texture2D _greenTextureDark;
  1142. Texture2D GreenTexture => EditorGUIUtility.isProSkin
  1143. ? _greenTextureDark ? _greenTextureDark : (_greenTextureDark = MakeTexture(0.5f))
  1144. : _greenTextureLight ? _greenTextureLight : (_greenTextureLight = MakeTexture(0.85f));
  1145. private void RenderProgressBar() {
  1146. if (currentState.downloadRequired && !currentState.downloadStarted) {
  1147. return;
  1148. }
  1149. using(var scope = new EditorGUILayout.VerticalScope(HotReloadWindowStyles.MiddleCenterStyle)) {
  1150. float progress;
  1151. var bg = HotReloadWindowStyles.ProgressBarBarStyle.normal.background;
  1152. try {
  1153. HotReloadWindowStyles.ProgressBarBarStyle.normal.background = GreenTexture;
  1154. var barRect = scope.rect;
  1155. barRect.height = 25;
  1156. if (currentState.downloadRequired) {
  1157. barRect.width = barRect.width - 65;
  1158. using (new EditorGUILayout.HorizontalScope()) {
  1159. progress = EditorCodePatcher.DownloadProgress;
  1160. EditorGUI.ProgressBar(barRect, Mathf.Clamp(progress, 0f, 1f), "");
  1161. if (GUI.Button(new Rect(barRect) { x = barRect.x + barRect.width + 5, height = barRect.height, width = 60 }, new GUIContent(" Info", GUIHelper.GetLocalIcon("alert_info")))) {
  1162. Application.OpenURL(Constants.AdditionalContentURL);
  1163. }
  1164. }
  1165. } else {
  1166. progress = EditorCodePatcher.Stopping ? 1 : Mathf.Clamp(EditorCodePatcher.StartupProgress?.Item1 ?? 0f, 0f, 1f);
  1167. EditorGUI.ProgressBar(barRect, progress, "");
  1168. }
  1169. GUILayout.Space(barRect.height);
  1170. } finally {
  1171. HotReloadWindowStyles.ProgressBarBarStyle.normal.background = bg;
  1172. }
  1173. }
  1174. }
  1175. private Texture2D MakeTexture(float maxHue) {
  1176. var width = 11;
  1177. var height = 11;
  1178. Color[] pix = new Color[width * height];
  1179. for (int y = 0; y < height; y++) {
  1180. var middle = Math.Ceiling(height / (double)2);
  1181. var maxGreen = maxHue;
  1182. var yCoord = y + 1;
  1183. var green = maxGreen - Math.Abs(yCoord - middle) * 0.02;
  1184. for (int x = 0; x < width; x++) {
  1185. pix[y * width + x] = new Color(0.1f, (float)green, 0.1f, 1.0f);
  1186. }
  1187. }
  1188. var result = new Texture2D(width, height);
  1189. result.SetPixels(pix);
  1190. result.Apply();
  1191. return result;
  1192. }
  1193. /*
  1194. [MenuItem("codepatcher/restart")]
  1195. public static void TestRestart() {
  1196. CodePatcherCLI.Restart(Application.dataPath, false);
  1197. }
  1198. */
  1199. }
  1200. internal static class HotReloadGUIHelper {
  1201. public static bool LinkLabel(string labelText, int fontSize, FontStyle fontStyle, TextAnchor alignment, Color? color = null) {
  1202. var stl = EditorStyles.label;
  1203. // copy
  1204. var origSize = stl.fontSize;
  1205. var origStyle = stl.fontStyle;
  1206. var origAnchor = stl.alignment;
  1207. var origColor = stl.normal.textColor;
  1208. // temporarily modify the built-in style
  1209. stl.fontSize = fontSize;
  1210. stl.fontStyle = fontStyle;
  1211. stl.alignment = alignment;
  1212. stl.normal.textColor = color ?? origColor;
  1213. stl.active.textColor = color ?? origColor;
  1214. stl.focused.textColor = color ?? origColor;
  1215. stl.hover.textColor = color ?? origColor;
  1216. try {
  1217. return GUILayout.Button(labelText, stl);
  1218. } finally{
  1219. // set the editor style (stl) back to normal
  1220. stl.fontSize = origSize;
  1221. stl.fontStyle = origStyle;
  1222. stl.alignment = origAnchor;
  1223. stl.normal.textColor = origColor;
  1224. stl.active.textColor = origColor;
  1225. stl.focused.textColor = origColor;
  1226. stl.hover.textColor = origColor;
  1227. }
  1228. }
  1229. public static void HelpBox(string message, MessageType type, int fontSize) {
  1230. var _fontSize = EditorStyles.helpBox.fontSize;
  1231. try {
  1232. EditorStyles.helpBox.fontSize = fontSize;
  1233. EditorGUILayout.HelpBox(message, type);
  1234. } finally {
  1235. EditorStyles.helpBox.fontSize = _fontSize;
  1236. }
  1237. }
  1238. }
  1239. internal enum PromoCodeErrorType {
  1240. NONE,
  1241. MISSING_INPUT,
  1242. INVALID_HTTP_METHOD,
  1243. BODY_INVALID,
  1244. PROMO_CODE_NOT_FOUND,
  1245. PROMO_CODE_CLAIMED,
  1246. PROMO_CODE_EXPIRED,
  1247. LICENSE_NOT_FOUND,
  1248. LICENSE_NOT_TRIAL,
  1249. LICENSE_ALREADY_EXTENDED,
  1250. UPDATING_LICENSE_FAILED,
  1251. CONDITIONAL_CHECK_FAILED,
  1252. UNKNOWN_EXCEPTION,
  1253. UNSUPPORTED_PATH,
  1254. }
  1255. internal class LoginData {
  1256. public readonly string email;
  1257. public readonly string password;
  1258. public LoginData(string email, string password) {
  1259. this.email = email;
  1260. this.password = password;
  1261. }
  1262. }
  1263. }