HotReloadRunTab.cs 74 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389
  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;
  830. if (EditorCodePatcher.licenseType == UnityLicenseType.UnityPersonalPlus) {
  831. message = "Unity Plus users require an Indie license. Please upgrade your license on our website.";
  832. } else if (EditorCodePatcher.licenseType == UnityLicenseType.UnityPro) {
  833. message = "Unity Pro/Enterprise users from company with your number of employees require an Indie license. Please upgrade your license on our website.";
  834. } else {
  835. return;
  836. }
  837. GUILayout.Space(8);
  838. using (new EditorGUILayout.HorizontalScope()) {
  839. EditorGUILayout.HelpBox(message, MessageType.Info);
  840. if (Event.current.type == EventType.Repaint) {
  841. style.fixedHeight = GUILayoutUtility.GetLastRect().height;
  842. }
  843. if (GUILayout.Button("Upgrade", style)) {
  844. Application.OpenURL(Constants.ProductPurchaseURL);
  845. }
  846. }
  847. }
  848. const string GetLicense = "Get License";
  849. const string ContactSupport = "Contact Support";
  850. const string UpgradeLicense = "Upgrade License";
  851. const string ManageLicense = "Manage License";
  852. internal static Dictionary<string, LicenseErrorData> _licenseErrorData;
  853. internal static Dictionary<string, LicenseErrorData> LicenseErrorData => _licenseErrorData ?? (_licenseErrorData = new Dictionary<string, LicenseErrorData> {
  854. { "DeviceNotLicensedException", new LicenseErrorData(description: "Another device is using your license. Please reach out to customer support for assistance.", showSupportButton: true, supportButtonText: ContactSupport) },
  855. { "DeviceBlacklistedException", new LicenseErrorData(description: "You device has been blacklisted.") },
  856. { "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.") },
  857. { "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.") },
  858. { "LicenseActivationException", new LicenseErrorData(description: "An error has occured while activating your license. Please contact customer support for assistance.", showSupportButton: true, supportButtonText: ContactSupport) },
  859. { "LicenseDeletedException", new LicenseErrorData(description: $"Your license has been deleted. Please contact customer support for assistance.", showBuyButton: true, buyButtonText: GetLicense, showSupportButton: true, supportButtonText: ContactSupport) },
  860. { "LicenseDisabledException", new LicenseErrorData(description: $"Your license has been disabled. Please contact customer support for assistance.", showBuyButton: true, buyButtonText: GetLicense, showSupportButton: true, supportButtonText: ContactSupport) },
  861. { "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) },
  862. { "LicenseInactiveException", new LicenseErrorData(description: $"Your license is currenty inactive. Please login with your email/password to activate your license.") },
  863. { "LocalLicenseException", new LicenseErrorData(description: $"Your license file was damaged or corrupted. Please login with your email/password to refresh your license file.") },
  864. // Note: obsolete
  865. { "MissingParametersException", new LicenseErrorData(description: "An account already exists for this device. Please login with your existing email/password.", showBuyButton: true, buyButtonText: GetLicense) },
  866. { "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) },
  867. { "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) },
  868. { "InvalidCredentialException", new LicenseErrorData(description: "Incorrect email/password. You can find your initial password in the sign-up email.") },
  869. // Note: activating free trial with email is not supported anymore. This error shouldn't happen which is why we should rather user the fallback
  870. // { "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) },
  871. { "LicenseIncompatibleException", new LicenseErrorData(description: "Please upgrade your license to continue using hotreload with Unity Pro.", showManageLicenseButton: true, manageLicenseButtonText: ManageLicense) },
  872. });
  873. 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);
  874. internal static string GetMessageFromError(HotReloadRunTabState currentState, string error) {
  875. if (PackageConst.IsAssetStoreBuild && error == "TrialLicenseExpiredException") {
  876. return assetStoreProInfo;
  877. }
  878. return GetLicenseErrorDataOrDefault(currentState, error).description;
  879. }
  880. internal static LicenseErrorData GetLicenseErrorDataOrDefault(HotReloadRunTabState currentState, string error) {
  881. if (currentState.loginStatus?.isFree == true) {
  882. return default(LicenseErrorData);
  883. }
  884. if (currentState.loginStatus == null || string.IsNullOrEmpty(error) && (!currentState.loginStatus.isLicensed || currentState.loginStatus.isTrial)) {
  885. return new LicenseErrorData(null, showBuyButton: true, buyButtonText: GetLicense);
  886. }
  887. if (string.IsNullOrEmpty(error)) {
  888. return default(LicenseErrorData);
  889. }
  890. if (!LicenseErrorData.ContainsKey(error)) {
  891. return defaultLicenseErrorData;
  892. }
  893. return LicenseErrorData[error];
  894. }
  895. internal static void RenderBuyLicenseButton(string buyLicenseButton) {
  896. OpenURLButton.Render(buyLicenseButton, Constants.ProductPurchaseURL);
  897. }
  898. static void RenderLicenseActionButtons(HotReloadRunTabState currentState) {
  899. var errInfo = GetLicenseErrorDataOrDefault(currentState, currentState.loginStatus?.lastLicenseError);
  900. if (errInfo.showBuyButton || errInfo.showManageLicenseButton) {
  901. using(new EditorGUILayout.HorizontalScope()) {
  902. if (errInfo.showBuyButton) {
  903. RenderBuyLicenseButton(errInfo.buyButtonText);
  904. }
  905. if (errInfo.showManageLicenseButton && !HotReloadPrefs.ErrorHidden) {
  906. OpenURLButton.Render(errInfo.manageLicenseButtonText, Constants.ManageLicenseURL);
  907. }
  908. }
  909. }
  910. if (errInfo.showLoginButton && GUILayout.Button(errInfo.loginButtonText, openSettingsStyle)) {
  911. // show license section
  912. HotReloadWindow.Current.SelectTab(typeof(HotReloadSettingsTab));
  913. HotReloadWindow.Current.SettingsTab.FocusLicenseFoldout();
  914. }
  915. if (errInfo.showSupportButton && !HotReloadPrefs.ErrorHidden) {
  916. OpenURLButton.Render(errInfo.supportButtonText, Constants.ContactURL);
  917. }
  918. if (currentState.loginStatus?.lastLicenseError != null) {
  919. HotReloadAboutTab.reportIssueButton.OnGUI();
  920. }
  921. }
  922. internal static void RenderLicenseInfo(HotReloadRunTabState currentState, LoginStatusResponse loginStatus, bool verbose = false, bool allowHide = true, string overrideActionButton = null, bool showConsumptions = false) {
  923. HotReloadPrefs.ShowLogin = EditorGUILayout.Foldout(HotReloadPrefs.ShowLogin, "Hot Reload License", true, HotReloadWindowStyles.FoldoutStyle);
  924. if (HotReloadPrefs.ShowLogin) {
  925. EditorGUILayout.Space();
  926. if ((loginStatus?.isLicensed != true && showConsumptions) && !(loginStatus == null || loginStatus.isFree)) {
  927. RenderConsumption(loginStatus);
  928. }
  929. RenderLicenseStatusInfo(currentState, loginStatus: loginStatus, allowHide: allowHide, verbose: verbose);
  930. RenderLicenseInnerPanel(currentState, overrideActionButton: overrideActionButton);
  931. EditorGUILayout.Space();
  932. EditorGUILayout.Space();
  933. }
  934. }
  935. internal void RenderPromoCodes() {
  936. HotReloadPrefs.ShowPromoCodes = EditorGUILayout.Foldout(HotReloadPrefs.ShowPromoCodes, "Promo Codes", true, HotReloadWindowStyles.FoldoutStyle);
  937. if (!HotReloadPrefs.ShowPromoCodes) {
  938. return;
  939. }
  940. if (promoCodeActivatedThisSession) {
  941. EditorGUILayout.HelpBox($"Your promo code has been successfully activated. Free trial has been extended by 3 months.", MessageType.Info);
  942. } else {
  943. if (promoCodeError != null && promoCodeErrorType != MessageType.None) {
  944. EditorGUILayout.HelpBox(promoCodeError, promoCodeErrorType);
  945. }
  946. EditorGUILayout.LabelField("Promo code");
  947. _pendingPromoCode = EditorGUILayout.TextField(_pendingPromoCode);
  948. EditorGUILayout.Space();
  949. using (new EditorGUI.DisabledScope(_requestingActivatePromoCode)) {
  950. if (GUILayout.Button("Activate promo code", HotReloadRunTab.bigButtonHeight)) {
  951. RequestActivatePromoCode().Forget();
  952. }
  953. }
  954. }
  955. EditorGUILayout.Space();
  956. EditorGUILayout.Space();
  957. }
  958. private async Task RequestActivatePromoCode() {
  959. _requestingActivatePromoCode = true;
  960. try {
  961. var resp = await RequestHelper.RequestActivatePromoCode(_pendingPromoCode);
  962. if (resp != null && resp.error == null) {
  963. promoCodeActivatedThisSession = true;
  964. } else {
  965. var requestError = resp?.error ?? "Network error";
  966. var errorType = ToErrorType(requestError);
  967. promoCodeError = ToPrettyErrorMessage(errorType);
  968. promoCodeErrorType = ToMessageType(errorType);
  969. }
  970. } finally {
  971. _requestingActivatePromoCode = false;
  972. }
  973. }
  974. PromoCodeErrorType ToErrorType(string error) {
  975. switch (error) {
  976. case "Input is missing": return PromoCodeErrorType.MISSING_INPUT;
  977. case "only POST is supported": return PromoCodeErrorType.INVALID_HTTP_METHOD;
  978. case "body is not a valid json": return PromoCodeErrorType.BODY_INVALID;
  979. case "Promo code is not found": return PromoCodeErrorType.PROMO_CODE_NOT_FOUND;
  980. case "Promo code already claimed": return PromoCodeErrorType.PROMO_CODE_CLAIMED;
  981. case "Promo code expired": return PromoCodeErrorType.PROMO_CODE_EXPIRED;
  982. case "License not found": return PromoCodeErrorType.LICENSE_NOT_FOUND;
  983. case "License is not a trial": return PromoCodeErrorType.LICENSE_NOT_TRIAL;
  984. case "License already extended": return PromoCodeErrorType.LICENSE_ALREADY_EXTENDED;
  985. case "conditionalCheckFailed": return PromoCodeErrorType.CONDITIONAL_CHECK_FAILED;
  986. }
  987. if (error.Contains("Updating License Failed with error")) {
  988. return PromoCodeErrorType.UPDATING_LICENSE_FAILED;
  989. } else if (error.Contains("Unknown exception")) {
  990. return PromoCodeErrorType.UNKNOWN_EXCEPTION;
  991. } else if (error.Contains("Unsupported path")) {
  992. return PromoCodeErrorType.UNSUPPORTED_PATH;
  993. }
  994. return PromoCodeErrorType.NONE;
  995. }
  996. string ToPrettyErrorMessage(PromoCodeErrorType errorType) {
  997. var defaultMsg = "We apologize, an error happened while activating your promo code. Please reach out to customer support for assistance.";
  998. switch (errorType) {
  999. case PromoCodeErrorType.MISSING_INPUT:
  1000. case PromoCodeErrorType.INVALID_HTTP_METHOD:
  1001. case PromoCodeErrorType.BODY_INVALID:
  1002. case PromoCodeErrorType.UNKNOWN_EXCEPTION:
  1003. case PromoCodeErrorType.UNSUPPORTED_PATH:
  1004. case PromoCodeErrorType.LICENSE_NOT_FOUND:
  1005. case PromoCodeErrorType.UPDATING_LICENSE_FAILED:
  1006. case PromoCodeErrorType.LICENSE_NOT_TRIAL:
  1007. return defaultMsg;
  1008. case PromoCodeErrorType.PROMO_CODE_NOT_FOUND: return "Your promo code is invalid. Please ensure that you have entered the correct promo code.";
  1009. case PromoCodeErrorType.PROMO_CODE_CLAIMED: return "Your promo code has already been used.";
  1010. case PromoCodeErrorType.PROMO_CODE_EXPIRED: return "Your promo code has expired.";
  1011. 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.";
  1012. 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.";
  1013. 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.";
  1014. default: return defaultMsg;
  1015. }
  1016. }
  1017. MessageType ToMessageType(PromoCodeErrorType errorType) {
  1018. switch (errorType) {
  1019. case PromoCodeErrorType.MISSING_INPUT: return MessageType.Error;
  1020. case PromoCodeErrorType.INVALID_HTTP_METHOD: return MessageType.Error;
  1021. case PromoCodeErrorType.BODY_INVALID: return MessageType.Error;
  1022. case PromoCodeErrorType.PROMO_CODE_NOT_FOUND: return MessageType.Warning;
  1023. case PromoCodeErrorType.PROMO_CODE_CLAIMED: return MessageType.Warning;
  1024. case PromoCodeErrorType.PROMO_CODE_EXPIRED: return MessageType.Warning;
  1025. case PromoCodeErrorType.LICENSE_NOT_FOUND: return MessageType.Error;
  1026. case PromoCodeErrorType.LICENSE_NOT_TRIAL: return MessageType.Error;
  1027. case PromoCodeErrorType.LICENSE_ALREADY_EXTENDED: return MessageType.Warning;
  1028. case PromoCodeErrorType.UPDATING_LICENSE_FAILED: return MessageType.Error;
  1029. case PromoCodeErrorType.CONDITIONAL_CHECK_FAILED: return MessageType.Error;
  1030. case PromoCodeErrorType.UNKNOWN_EXCEPTION: return MessageType.Error;
  1031. case PromoCodeErrorType.UNSUPPORTED_PATH: return MessageType.Error;
  1032. case PromoCodeErrorType.NONE: return MessageType.Error;
  1033. default: return MessageType.Error;
  1034. }
  1035. }
  1036. public static void RenderLicenseButtons(HotReloadRunTabState currentState) {
  1037. RenderLicenseActionButtons(currentState);
  1038. }
  1039. internal static void RenderLicenseInnerPanel(HotReloadRunTabState currentState, string overrideActionButton = null, bool renderLogout = true) {
  1040. EditorGUILayout.LabelField("Email");
  1041. GUI.SetNextControlName("email");
  1042. _pendingEmail = EditorGUILayout.TextField(string.IsNullOrEmpty(_pendingEmail) ? HotReloadPrefs.LicenseEmail : _pendingEmail);
  1043. _pendingEmail = _pendingEmail.Trim();
  1044. EditorGUILayout.LabelField("Password");
  1045. GUI.SetNextControlName("password");
  1046. _pendingPassword = EditorGUILayout.PasswordField(string.IsNullOrEmpty(_pendingPassword) ? HotReloadPrefs.LicensePassword : _pendingPassword);
  1047. RenderSwitchAuthMode();
  1048. var e = Event.current;
  1049. using(new EditorGUI.DisabledScope(currentState.requestingLoginInfo)) {
  1050. var btnLabel = overrideActionButton;
  1051. if (String.IsNullOrEmpty(overrideActionButton)) {
  1052. btnLabel = "Login";
  1053. }
  1054. using (new EditorGUILayout.HorizontalScope()) {
  1055. var focusedControl = GUI.GetNameOfFocusedControl();
  1056. if (GUILayout.Button(btnLabel, bigButtonHeight)
  1057. || (focusedControl == "email"
  1058. || focusedControl == "password")
  1059. && e.type == EventType.KeyUp
  1060. && (e.keyCode == KeyCode.Return
  1061. || e.keyCode == KeyCode.KeypadEnter)
  1062. ) {
  1063. var error = ValidateEmail(_pendingEmail);
  1064. if (!string.IsNullOrEmpty(error)) {
  1065. _activateInfoMessage = new Tuple<string, MessageType>(error, MessageType.Warning);
  1066. } else if (string.IsNullOrEmpty(_pendingPassword)) {
  1067. _activateInfoMessage = new Tuple<string, MessageType>("Please enter your password.", MessageType.Warning);
  1068. } else {
  1069. HotReloadWindow.Current.SelectTab(typeof(HotReloadRunTab));
  1070. _activateInfoMessage = null;
  1071. if (RedeemLicenseHelper.I.RedeemStage == RedeemStage.Login) {
  1072. RedeemLicenseHelper.I.FinishRegistration(RegistrationOutcome.Indie);
  1073. }
  1074. if (!EditorCodePatcher.RequestingDownloadAndRun && !EditorCodePatcher.Running) {
  1075. LoginOnDownloadAndRun(new LoginData(email: _pendingEmail, password: _pendingPassword)).Forget();
  1076. } else {
  1077. EditorCodePatcher.RequestLogin(_pendingEmail, _pendingPassword).Forget();
  1078. }
  1079. }
  1080. }
  1081. if (renderLogout) {
  1082. RenderLogout(currentState);
  1083. }
  1084. }
  1085. }
  1086. if (_activateInfoMessage != null && (e.type == EventType.Layout || e.type == EventType.Repaint)) {
  1087. EditorGUILayout.HelpBox(_activateInfoMessage.Item1, _activateInfoMessage.Item2);
  1088. }
  1089. }
  1090. public static string ValidateEmail(string email) {
  1091. if (string.IsNullOrEmpty(email)) {
  1092. return "Please enter your email address.";
  1093. } else if (!EditorWindowHelper.IsValidEmailAddress(email)) {
  1094. return "Please enter a valid email address.";
  1095. } else if (email.Contains("+")) {
  1096. 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.";
  1097. }
  1098. return null;
  1099. }
  1100. public static void RenderLogout(HotReloadRunTabState currentState) {
  1101. if (currentState.loginStatus?.isLicensed != true) {
  1102. return;
  1103. }
  1104. if (GUILayout.Button("Logout", bigButtonHeight)) {
  1105. HotReloadWindow.Current.SelectTab(typeof(HotReloadRunTab));
  1106. if (!EditorCodePatcher.RequestingDownloadAndRun && !EditorCodePatcher.Running) {
  1107. LogoutOnDownloadAndRun().Forget();
  1108. } else {
  1109. RequestLogout().Forget();
  1110. }
  1111. }
  1112. }
  1113. async static Task LoginOnDownloadAndRun(LoginData loginData = null) {
  1114. var ok = await EditorCodePatcher.DownloadAndRun(loginData);
  1115. if (ok && loginData != null) {
  1116. HotReloadPrefs.ErrorHidden = false;
  1117. HotReloadPrefs.LicenseEmail = loginData.email;
  1118. HotReloadPrefs.LicensePassword = loginData.password;
  1119. }
  1120. }
  1121. async static Task LogoutOnDownloadAndRun() {
  1122. var ok = await EditorCodePatcher.DownloadAndRun();
  1123. if (!ok) {
  1124. return;
  1125. }
  1126. await RequestLogout();
  1127. }
  1128. private async static Task RequestLogout() {
  1129. int i = 0;
  1130. while (!EditorCodePatcher.Running && i < 100) {
  1131. await Task.Delay(100);
  1132. i++;
  1133. }
  1134. var resp = await RequestHelper.RequestLogout();
  1135. if (!EditorCodePatcher.RequestingLoginInfo && resp != null) {
  1136. EditorCodePatcher.HandleStatus(resp);
  1137. }
  1138. }
  1139. private static void RenderSwitchAuthMode() {
  1140. var color = EditorGUIUtility.isProSkin ? new Color32(0x3F, 0x9F, 0xFF, 0xFF) : new Color32(0x0F, 0x52, 0xD7, 0xFF);
  1141. if (HotReloadGUIHelper.LinkLabel("Forgot password?", 12, FontStyle.Normal, TextAnchor.MiddleLeft, color)) {
  1142. 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")) {
  1143. Application.OpenURL(Constants.ForgotPasswordURL);
  1144. }
  1145. }
  1146. }
  1147. Texture2D _greenTextureLight;
  1148. Texture2D _greenTextureDark;
  1149. Texture2D GreenTexture => EditorGUIUtility.isProSkin
  1150. ? _greenTextureDark ? _greenTextureDark : (_greenTextureDark = MakeTexture(0.5f))
  1151. : _greenTextureLight ? _greenTextureLight : (_greenTextureLight = MakeTexture(0.85f));
  1152. private void RenderProgressBar() {
  1153. if (currentState.downloadRequired && !currentState.downloadStarted) {
  1154. return;
  1155. }
  1156. using(var scope = new EditorGUILayout.VerticalScope(HotReloadWindowStyles.MiddleCenterStyle)) {
  1157. float progress;
  1158. var bg = HotReloadWindowStyles.ProgressBarBarStyle.normal.background;
  1159. try {
  1160. HotReloadWindowStyles.ProgressBarBarStyle.normal.background = GreenTexture;
  1161. var barRect = scope.rect;
  1162. barRect.height = 25;
  1163. if (currentState.downloadRequired) {
  1164. barRect.width = barRect.width - 65;
  1165. using (new EditorGUILayout.HorizontalScope()) {
  1166. progress = EditorCodePatcher.DownloadProgress;
  1167. EditorGUI.ProgressBar(barRect, Mathf.Clamp(progress, 0f, 1f), "");
  1168. if (GUI.Button(new Rect(barRect) { x = barRect.x + barRect.width + 5, height = barRect.height, width = 60 }, new GUIContent(" Info", GUIHelper.GetLocalIcon("alert_info")))) {
  1169. Application.OpenURL(Constants.AdditionalContentURL);
  1170. }
  1171. }
  1172. } else {
  1173. progress = EditorCodePatcher.Stopping ? 1 : Mathf.Clamp(EditorCodePatcher.StartupProgress?.Item1 ?? 0f, 0f, 1f);
  1174. EditorGUI.ProgressBar(barRect, progress, "");
  1175. }
  1176. GUILayout.Space(barRect.height);
  1177. } finally {
  1178. HotReloadWindowStyles.ProgressBarBarStyle.normal.background = bg;
  1179. }
  1180. }
  1181. }
  1182. private Texture2D MakeTexture(float maxHue) {
  1183. var width = 11;
  1184. var height = 11;
  1185. Color[] pix = new Color[width * height];
  1186. for (int y = 0; y < height; y++) {
  1187. var middle = Math.Ceiling(height / (double)2);
  1188. var maxGreen = maxHue;
  1189. var yCoord = y + 1;
  1190. var green = maxGreen - Math.Abs(yCoord - middle) * 0.02;
  1191. for (int x = 0; x < width; x++) {
  1192. pix[y * width + x] = new Color(0.1f, (float)green, 0.1f, 1.0f);
  1193. }
  1194. }
  1195. var result = new Texture2D(width, height);
  1196. result.SetPixels(pix);
  1197. result.Apply();
  1198. return result;
  1199. }
  1200. /*
  1201. [MenuItem("codepatcher/restart")]
  1202. public static void TestRestart() {
  1203. CodePatcherCLI.Restart(Application.dataPath, false);
  1204. }
  1205. */
  1206. }
  1207. internal static class HotReloadGUIHelper {
  1208. public static bool LinkLabel(string labelText, int fontSize, FontStyle fontStyle, TextAnchor alignment, Color? color = null) {
  1209. var stl = EditorStyles.label;
  1210. // copy
  1211. var origSize = stl.fontSize;
  1212. var origStyle = stl.fontStyle;
  1213. var origAnchor = stl.alignment;
  1214. var origColor = stl.normal.textColor;
  1215. // temporarily modify the built-in style
  1216. stl.fontSize = fontSize;
  1217. stl.fontStyle = fontStyle;
  1218. stl.alignment = alignment;
  1219. stl.normal.textColor = color ?? origColor;
  1220. stl.active.textColor = color ?? origColor;
  1221. stl.focused.textColor = color ?? origColor;
  1222. stl.hover.textColor = color ?? origColor;
  1223. try {
  1224. return GUILayout.Button(labelText, stl);
  1225. } finally{
  1226. // set the editor style (stl) back to normal
  1227. stl.fontSize = origSize;
  1228. stl.fontStyle = origStyle;
  1229. stl.alignment = origAnchor;
  1230. stl.normal.textColor = origColor;
  1231. stl.active.textColor = origColor;
  1232. stl.focused.textColor = origColor;
  1233. stl.hover.textColor = origColor;
  1234. }
  1235. }
  1236. public static void HelpBox(string message, MessageType type, int fontSize) {
  1237. var _fontSize = EditorStyles.helpBox.fontSize;
  1238. try {
  1239. EditorStyles.helpBox.fontSize = fontSize;
  1240. EditorGUILayout.HelpBox(message, type);
  1241. } finally {
  1242. EditorStyles.helpBox.fontSize = _fontSize;
  1243. }
  1244. }
  1245. }
  1246. internal enum PromoCodeErrorType {
  1247. NONE,
  1248. MISSING_INPUT,
  1249. INVALID_HTTP_METHOD,
  1250. BODY_INVALID,
  1251. PROMO_CODE_NOT_FOUND,
  1252. PROMO_CODE_CLAIMED,
  1253. PROMO_CODE_EXPIRED,
  1254. LICENSE_NOT_FOUND,
  1255. LICENSE_NOT_TRIAL,
  1256. LICENSE_ALREADY_EXTENDED,
  1257. UPDATING_LICENSE_FAILED,
  1258. CONDITIONAL_CHECK_FAILED,
  1259. UNKNOWN_EXCEPTION,
  1260. UNSUPPORTED_PATH,
  1261. }
  1262. internal class LoginData {
  1263. public readonly string email;
  1264. public readonly string password;
  1265. public LoginData(string email, string password) {
  1266. this.email = email;
  1267. this.password = password;
  1268. }
  1269. }
  1270. }