maint: hotreload updated to 1.13.7
This commit is contained in:
@@ -5,6 +5,7 @@ using System.IO;
|
||||
using UnityEditor;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using SingularityGroup.HotReload.Editor.Localization;
|
||||
using SingularityGroup.HotReload.Newtonsoft.Json;
|
||||
using UnityEditor.Compilation;
|
||||
|
||||
@@ -14,12 +15,12 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
internal static class AssemblyOmission {
|
||||
// [MenuItem("Window/Hot Reload Dev/List omitted projects")]
|
||||
private static void Check() {
|
||||
Log.Info("To compile C# files same as a Player build, we must omit projects which aren't part of the selected Player build.");
|
||||
Log.Info(Translations.Errors.InfoOmitProjectsForPlayerBuild);
|
||||
var omitted = GetOmittedProjects(EditorUserBuildSettings.activeScriptCompilationDefines);
|
||||
Log.Info("---------");
|
||||
Log.Info(Translations.Errors.InfoSeparator);
|
||||
|
||||
foreach (var name in omitted) {
|
||||
Log.Info("omitted editor/other project named: {0}", name);
|
||||
Log.Info(Translations.Errors.InfoOmittedEditorProject, name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,10 +70,10 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
|
||||
if (verboseLogs) {
|
||||
foreach (var name in editorAssemblies) {
|
||||
Log.Info("found project named {0}", name);
|
||||
Log.Info(Translations.Errors.InfoFoundProjectNamed, name);
|
||||
}
|
||||
foreach (var playerAssemblyName in playerAssemblies) {
|
||||
Log.Debug("player assembly named {0}", playerAssemblyName);
|
||||
Log.Debug(string.Format(Translations.Utility.PlayerAssemblyDebug, playerAssemblyName));
|
||||
}
|
||||
}
|
||||
// leaves the editor assemblies that are not built into player assemblies (e.g. editor and test assemblies)
|
||||
|
||||
@@ -12,12 +12,14 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
public readonly BuildTarget activeBuildTarget;
|
||||
public readonly string[] omittedProjects;
|
||||
public readonly bool batchMode;
|
||||
public readonly string locale;
|
||||
|
||||
public BuildInfoInput(string allDefineSymbols, BuildTarget activeBuildTarget, string[] omittedProjects, bool batchMode) {
|
||||
public BuildInfoInput(string allDefineSymbols, BuildTarget activeBuildTarget, string[] omittedProjects, bool batchMode, string locale) {
|
||||
this.allDefineSymbols = allDefineSymbols;
|
||||
this.activeBuildTarget = activeBuildTarget;
|
||||
this.omittedProjects = omittedProjects;
|
||||
this.batchMode = batchMode;
|
||||
this.locale = locale;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,12 +33,14 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
});
|
||||
// cached so unexpensive most of the time
|
||||
var omittedProjects = AssemblyOmission.GetOmittedProjects(allDefineSymbols);
|
||||
var locale = PackageConst.DefaultLocale;
|
||||
|
||||
return new BuildInfoInput(
|
||||
allDefineSymbols: allDefineSymbols,
|
||||
activeBuildTarget: buildTarget,
|
||||
omittedProjects: omittedProjects,
|
||||
batchMode: batchMode
|
||||
batchMode: batchMode,
|
||||
locale: locale
|
||||
);
|
||||
}
|
||||
|
||||
@@ -50,7 +54,8 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
allDefineSymbols: allDefineSymbols,
|
||||
activeBuildTarget: buildTarget,
|
||||
omittedProjects: AssemblyOmission.GetOmittedProjects(allDefineSymbols),
|
||||
batchMode: Application.isBatchMode
|
||||
batchMode: Application.isBatchMode,
|
||||
locale: PackageConst.DefaultLocale
|
||||
));
|
||||
}
|
||||
|
||||
@@ -72,6 +77,7 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
buildMachinePort = RequestHelper.port,
|
||||
activeBuildTarget = input.activeBuildTarget.ToString(),
|
||||
buildMachineRequestOrigin = RequestHelper.origin,
|
||||
locale = input.locale
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Threading.Tasks;
|
||||
using UnityEditor;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using SingularityGroup.HotReload.Editor.Localization;
|
||||
|
||||
namespace SingularityGroup.HotReload.Editor {
|
||||
internal static class EditorWindowHelper {
|
||||
@@ -37,9 +38,9 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
NeedsRecompile
|
||||
}
|
||||
|
||||
private static readonly Dictionary<NotificationStatus, GUIContent> notificationContent = new Dictionary<NotificationStatus, GUIContent> {
|
||||
{ NotificationStatus.Patching, new GUIContent("[Hot Reload] Applying patches...")},
|
||||
{ NotificationStatus.NeedsRecompile, new GUIContent("[Hot Reload] Unsupported Changes detected! Recompiling...")},
|
||||
private static Dictionary<NotificationStatus, GUIContent> notificationContent => new Dictionary<NotificationStatus, GUIContent> {
|
||||
{ NotificationStatus.Patching, new GUIContent(Translations.Miscellaneous.NotificationPatching)},
|
||||
{ NotificationStatus.NeedsRecompile, new GUIContent(Translations.Miscellaneous.NotificationNeedsRecompile)},
|
||||
};
|
||||
|
||||
static Type gameViewT;
|
||||
|
||||
@@ -4,11 +4,14 @@ using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using SingularityGroup.HotReload.DTO;
|
||||
using SingularityGroup.HotReload.Editor.Localization;
|
||||
using SingularityGroup.HotReload.Localization;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Compilation;
|
||||
using UnityEditor.PackageManager;
|
||||
using UnityEditor.PackageManager.Requests;
|
||||
using UnityEngine;
|
||||
using Translations = SingularityGroup.HotReload.Editor.Localization.Translations;
|
||||
|
||||
namespace SingularityGroup.HotReload.Editor {
|
||||
|
||||
@@ -111,19 +114,19 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
return null;
|
||||
}
|
||||
|
||||
internal static readonly OpenURLButton recompileTroubleshootingButton = new OpenURLButton("Docs", Constants.RecompileTroubleshootingURL);
|
||||
internal static readonly OpenURLButton featuresDocumentationButton = new OpenURLButton("Docs", Constants.FeaturesDocumentationURL);
|
||||
internal static readonly OpenURLButton multipleEditorsDocumentationButton = new OpenURLButton("Docs", Constants.MultipleEditorsURL);
|
||||
internal static readonly OpenURLButton debuggerDocumentationButton = new OpenURLButton("More Info", Constants.DebuggerURL);
|
||||
internal static readonly OpenURLButton recompileTroubleshootingButton = new OpenURLButton(Translations.Suggestions.ButtonDocs, Constants.RecompileTroubleshootingURL);
|
||||
internal static readonly OpenURLButton featuresDocumentationButton = new OpenURLButton(Translations.Suggestions.ButtonDocs, Constants.FeaturesDocumentationURL);
|
||||
internal static readonly OpenURLButton multipleEditorsDocumentationButton = new OpenURLButton(Translations.Suggestions.ButtonDocs, Constants.MultipleEditorsURL);
|
||||
internal static readonly OpenURLButton debuggerDocumentationButton = new OpenURLButton(Translations.Suggestions.ButtonMoreInfo, Constants.DebuggerURL);
|
||||
public static Dictionary<HotReloadSuggestionKind, AlertEntry> suggestionMap = new Dictionary<HotReloadSuggestionKind, AlertEntry> {
|
||||
{ HotReloadSuggestionKind.UnityBestDevelopmentToolAward2023, new AlertEntry(
|
||||
AlertType.Suggestion,
|
||||
"Vote for the \"Best Development Tool\" Award!",
|
||||
"Hot Reload was nominated for the \"Best Development Tool\" Award. Please consider voting. Thank you!",
|
||||
Translations.Suggestions.Award2023Title,
|
||||
Translations.Suggestions.Award2023Message,
|
||||
actionData: () => {
|
||||
GUILayout.Space(6f);
|
||||
using (new EditorGUILayout.HorizontalScope()) {
|
||||
if (GUILayout.Button(" Vote ")) {
|
||||
if (GUILayout.Button(Translations.Suggestions.ButtonVote)) {
|
||||
Application.OpenURL(Constants.VoteForAwardURL);
|
||||
SetSuggestionInactive(HotReloadSuggestionKind.UnityBestDevelopmentToolAward2023);
|
||||
}
|
||||
@@ -135,8 +138,8 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
)},
|
||||
{ HotReloadSuggestionKind.UnsupportedChanges, new AlertEntry(
|
||||
AlertType.Suggestion,
|
||||
"Which changes does Hot Reload support?",
|
||||
"Hot Reload supports most code changes, but there are some limitations. Generally, changes to methods and fields are supported. Things like adding new types is not (yet) supported. See the documentation for the list of current features and our current roadmap",
|
||||
Translations.Suggestions.UnsupportedChangesTitle,
|
||||
Translations.Suggestions.UnsupportedChangesMessage,
|
||||
actionData: () => {
|
||||
GUILayout.Space(10f);
|
||||
using (new EditorGUILayout.HorizontalScope()) {
|
||||
@@ -149,8 +152,8 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
)},
|
||||
{ HotReloadSuggestionKind.UnsupportedPackages, new AlertEntry(
|
||||
AlertType.Suggestion,
|
||||
"Unsupported package detected",
|
||||
"The following packages are only partially supported: ECS, Mirror, Fishnet, and Photon. Hot Reload will work in the project, but changes specific to those packages might not hot-reload",
|
||||
Translations.Suggestions.UnsupportedPackagesTitle,
|
||||
Translations.Suggestions.UnsupportedPackagesMessage,
|
||||
iconType: AlertType.UnsupportedChange,
|
||||
actionData: () => {
|
||||
GUILayout.Space(10f);
|
||||
@@ -164,8 +167,8 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
)},
|
||||
{ HotReloadSuggestionKind.AutoRecompiledWhenPlaymodeStateChanges, new AlertEntry(
|
||||
AlertType.Suggestion,
|
||||
"Unity recompiles on enter/exit play mode?",
|
||||
"If you have an issue with the Unity Editor recompiling when the Play Mode state changes, more info is available in the docs. Feel free to reach out if you require assistance. We'll be glad to help.",
|
||||
Translations.Suggestions.AutoRecompiledPlaymodeTitle,
|
||||
Translations.Suggestions.AutoRecompiledPlaymodeMessage,
|
||||
actionData: () => {
|
||||
GUILayout.Space(10f);
|
||||
using (new EditorGUILayout.HorizontalScope()) {
|
||||
@@ -183,23 +186,23 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
#if UNITY_2022_1_OR_NEWER
|
||||
{ HotReloadSuggestionKind.AutoRecompiledWhenPlaymodeStateChanges2022, new AlertEntry(
|
||||
AlertType.Suggestion,
|
||||
"Unsupported setting detected",
|
||||
"The 'Sprite Packer Mode' setting can cause unintended recompilations if set to 'Sprite Atlas V1 - Always Enabled'",
|
||||
Translations.Suggestions.AutoRecompiled2022Title,
|
||||
Translations.Suggestions.AutoRecompiled2022Message,
|
||||
iconType: AlertType.UnsupportedChange,
|
||||
actionData: () => {
|
||||
GUILayout.Space(10f);
|
||||
using (new EditorGUILayout.HorizontalScope()) {
|
||||
if (GUILayout.Button(" Use \"Build Time Only Atlas\" ")) {
|
||||
if (GUILayout.Button(Translations.Suggestions.ButtonUseBuildTimeOnlyAtlas)) {
|
||||
if (EditorSettings.spritePackerMode == SpritePackerMode.SpriteAtlasV2) {
|
||||
EditorSettings.spritePackerMode = SpritePackerMode.SpriteAtlasV2Build;
|
||||
} else {
|
||||
EditorSettings.spritePackerMode = SpritePackerMode.BuildTimeOnlyAtlas;
|
||||
}
|
||||
}
|
||||
if (GUILayout.Button(" Open Settings ")) {
|
||||
if (GUILayout.Button(Translations.Suggestions.ButtonOpenSettings)) {
|
||||
SettingsService.OpenProjectSettings("Project/Editor");
|
||||
}
|
||||
if (GUILayout.Button(" Ignore suggestion ")) {
|
||||
if (GUILayout.Button(Translations.Suggestions.ButtonIgnoreSuggestion)) {
|
||||
SetSuggestionInactive(HotReloadSuggestionKind.AutoRecompiledWhenPlaymodeStateChanges2022);
|
||||
}
|
||||
|
||||
@@ -213,14 +216,20 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
#endif
|
||||
{ HotReloadSuggestionKind.MultidimensionalArrays, new AlertEntry(
|
||||
AlertType.Suggestion,
|
||||
"Use jagged instead of multidimensional arrays",
|
||||
"Hot Reload doesn't support methods with multidimensional arrays ([,]). You can work around this by using jagged arrays ([][])",
|
||||
Translations.Suggestions.MultidimensionalArraysTitle,
|
||||
Translations.Suggestions.MultidimensionalArraysMessage,
|
||||
iconType: AlertType.UnsupportedChange,
|
||||
actionData: () => {
|
||||
GUILayout.Space(10f);
|
||||
using (new EditorGUILayout.HorizontalScope()) {
|
||||
if (GUILayout.Button(" Learn more ")) {
|
||||
Application.OpenURL("https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1814");
|
||||
if (GUILayout.Button(Translations.Suggestions.ButtonLearnMore)) {
|
||||
string url;
|
||||
if (PackageConst.DefaultLocaleField == Locale.SimplifiedChinese) {
|
||||
url = "https://learn.microsoft.com/zh-cn/dotnet/fundamentals/code-analysis/quality-rules/ca1814";
|
||||
} else {
|
||||
url = "https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1814";
|
||||
}
|
||||
Application.OpenURL(url);
|
||||
}
|
||||
GUILayout.FlexibleSpace();
|
||||
}
|
||||
@@ -230,12 +239,12 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
)},
|
||||
{ HotReloadSuggestionKind.EditorsWithoutHRRunning, new AlertEntry(
|
||||
AlertType.Suggestion,
|
||||
"Some Unity instances don't have Hot Reload running.",
|
||||
"Make sure that either: \n1) Hot Reload is installed and running on all Editor instances, or \n2) Hot Reload is stopped in all Editor instances where it is installed.",
|
||||
Translations.Suggestions.EditorsWithoutHRTitle,
|
||||
Translations.Suggestions.EditorsWithoutHRMessage,
|
||||
actionData: () => {
|
||||
GUILayout.Space(10f);
|
||||
using (new EditorGUILayout.HorizontalScope()) {
|
||||
if (GUILayout.Button(" Stop Hot Reload ")) {
|
||||
if (GUILayout.Button(Translations.Suggestions.ButtonStopHotReload)) {
|
||||
EditorCodePatcher.StopCodePatcher().Forget();
|
||||
}
|
||||
GUILayout.Space(5f);
|
||||
@@ -243,7 +252,7 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
multipleEditorsDocumentationButton.OnGUI();
|
||||
GUILayout.Space(5f);
|
||||
|
||||
if (GUILayout.Button(" Don't show again ")) {
|
||||
if (GUILayout.Button(Translations.Suggestions.ButtonDontShowAgain)) {
|
||||
HotReloadSuggestionsHelper.SetSuggestionsShown(HotReloadSuggestionKind.EditorsWithoutHRRunning);
|
||||
HotReloadSuggestionsHelper.SetSuggestionInactive(HotReloadSuggestionKind.EditorsWithoutHRRunning);
|
||||
}
|
||||
@@ -258,16 +267,16 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
// Not in use (never reported from the server)
|
||||
{ HotReloadSuggestionKind.FieldInitializerWithSideEffects, new AlertEntry(
|
||||
AlertType.Suggestion,
|
||||
"Field initializer with side-effects detected",
|
||||
"A field initializer update might have side effects, e.g. calling a method or creating an object.\n\nWhile Hot Reload does support this, it can sometimes be confusing when the initializer logic runs at 'unexpected times'.",
|
||||
Translations.Suggestions.FieldInitializerSideEffectsTitle,
|
||||
Translations.Suggestions.FieldInitializerSideEffectsMessage,
|
||||
actionData: () => {
|
||||
GUILayout.Space(10f);
|
||||
using (new EditorGUILayout.HorizontalScope()) {
|
||||
if (GUILayout.Button(" OK ")) {
|
||||
if (GUILayout.Button(Translations.Suggestions.ButtonOK)) {
|
||||
SetSuggestionInactive(HotReloadSuggestionKind.FieldInitializerWithSideEffects);
|
||||
}
|
||||
GUILayout.FlexibleSpace();
|
||||
if (GUILayout.Button(" Don't show again ")) {
|
||||
if (GUILayout.Button(Translations.Suggestions.ButtonDontShowAgain)) {
|
||||
SetSuggestionsShown(HotReloadSuggestionKind.FieldInitializerWithSideEffects);
|
||||
SetSuggestionInactive(HotReloadSuggestionKind.FieldInitializerWithSideEffects);
|
||||
}
|
||||
@@ -279,17 +288,17 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
)},
|
||||
{ HotReloadSuggestionKind.DetailedErrorReportingIsEnabled, new AlertEntry(
|
||||
AlertType.Suggestion,
|
||||
"Detailed error reporting is enabled",
|
||||
"When an error happens in Hot Reload, the exception stacktrace is sent as telemetry to help diagnose and fix the issue.\nThe exception stack trace is only included if it originated from the Hot Reload package or binary. Stacktraces from your own code are not sent.\nYou can disable detailed error reporting to prevent telemetry from including any information about your project.",
|
||||
Translations.Suggestions.DetailedErrorReportingTitle,
|
||||
Translations.Suggestions.DetailedErrorReportingMessage,
|
||||
actionData: () => {
|
||||
GUILayout.Space(10f);
|
||||
using (new EditorGUILayout.HorizontalScope()) {
|
||||
GUILayout.Space(4f);
|
||||
if (GUILayout.Button(" OK ")) {
|
||||
if (GUILayout.Button(Translations.Suggestions.ButtonOKPadded)) {
|
||||
SetSuggestionInactive(HotReloadSuggestionKind.DetailedErrorReportingIsEnabled);
|
||||
}
|
||||
GUILayout.FlexibleSpace();
|
||||
if (GUILayout.Button(" Disable ")) {
|
||||
if (GUILayout.Button(Translations.Suggestions.ButtonDisable)) {
|
||||
HotReloadSettingsTab.DisableDetailedErrorReportingInner(true);
|
||||
SetSuggestionInactive(HotReloadSuggestionKind.DetailedErrorReportingIsEnabled);
|
||||
}
|
||||
@@ -303,22 +312,22 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
// Not in use (never reported from the server)
|
||||
{ HotReloadSuggestionKind.FieldInitializerExistingInstancesEdited, new AlertEntry(
|
||||
AlertType.Suggestion,
|
||||
"Field initializer edit updated the value of existing class instances",
|
||||
"By default, Hot Reload updates field values of existing object instances when new field initializer has constant value.\n\nIf you want to change this behavior, disable the \"Apply field initializer edits to existing class instances\" option in Settings or click the button below.",
|
||||
Translations.Suggestions.FieldInitializerEditedTitle,
|
||||
Translations.Suggestions.FieldInitializerEditedMessage,
|
||||
actionData: () => {
|
||||
GUILayout.Space(10f);
|
||||
using (new EditorGUILayout.HorizontalScope()) {
|
||||
if (GUILayout.Button(" Turn off ")) {
|
||||
if (GUILayout.Button(Translations.Suggestions.ButtonTurnOff)) {
|
||||
#pragma warning disable CS0618
|
||||
HotReloadSettingsTab.ApplyApplyFieldInitializerEditsToExistingClassInstances(false);
|
||||
#pragma warning restore CS0618
|
||||
SetSuggestionInactive(HotReloadSuggestionKind.FieldInitializerExistingInstancesEdited);
|
||||
}
|
||||
if (GUILayout.Button(" Open Settings ")) {
|
||||
if (GUILayout.Button(Translations.Suggestions.ButtonOpenSettings)) {
|
||||
HotReloadWindow.Current.SelectTab(typeof(HotReloadSettingsTab));
|
||||
}
|
||||
GUILayout.FlexibleSpace();
|
||||
if (GUILayout.Button(" Don't show again ")) {
|
||||
if (GUILayout.Button(Translations.Suggestions.ButtonDontShowAgain)) {
|
||||
SetSuggestionsShown(HotReloadSuggestionKind.FieldInitializerExistingInstancesEdited);
|
||||
SetSuggestionInactive(HotReloadSuggestionKind.FieldInitializerExistingInstancesEdited);
|
||||
}
|
||||
@@ -330,12 +339,12 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
)},
|
||||
{ HotReloadSuggestionKind.FieldInitializerExistingInstancesUnedited, new AlertEntry(
|
||||
AlertType.Suggestion,
|
||||
"Field initializer edits don't apply to existing objects",
|
||||
"By default, Hot Reload applies field initializer edits of existing fields only to new objects (newly instantiated classes), just like normal C#.\n\nFor rapid prototyping, you can use static fields which will update across all instances.",
|
||||
Translations.Suggestions.FieldInitializerUneditedTitle,
|
||||
Translations.Suggestions.FieldInitializerUneditedMessage,
|
||||
actionData: () => {
|
||||
GUILayout.Space(8f);
|
||||
using (new EditorGUILayout.HorizontalScope()) {
|
||||
if (GUILayout.Button(" OK ")) {
|
||||
if (GUILayout.Button(Translations.Suggestions.ButtonOK)) {
|
||||
SetSuggestionsShown(HotReloadSuggestionKind.FieldInitializerExistingInstancesUnedited);
|
||||
SetSuggestionInactive(HotReloadSuggestionKind.FieldInitializerExistingInstancesUnedited);
|
||||
}
|
||||
@@ -348,22 +357,22 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
)},
|
||||
{ HotReloadSuggestionKind.AddMonobehaviourMethod, new AlertEntry(
|
||||
AlertType.Suggestion,
|
||||
"New MonoBehaviour methods are not shown in the inspector",
|
||||
"New methods in MonoBehaviours are not shown in the inspector until the script is recompiled. This is a limitation of Hot Reload handling of Unity's serialization system.\n\nYou can use the button below to auto recompile partially supported changes such as this one.",
|
||||
Translations.Suggestions.AddMonobehaviourMethodTitle,
|
||||
Translations.Suggestions.AddMonobehaviourMethodMessage,
|
||||
actionData: () => {
|
||||
GUILayout.Space(8f);
|
||||
using (new EditorGUILayout.HorizontalScope()) {
|
||||
if (GUILayout.Button(" OK ")) {
|
||||
if (GUILayout.Button(Translations.Suggestions.ButtonOK)) {
|
||||
SetSuggestionInactive(HotReloadSuggestionKind.AddMonobehaviourMethod);
|
||||
}
|
||||
if (GUILayout.Button(" Auto Recompile ")) {
|
||||
if (GUILayout.Button(Translations.Suggestions.ButtonAutoRecompile)) {
|
||||
SetSuggestionInactive(HotReloadSuggestionKind.AddMonobehaviourMethod);
|
||||
HotReloadPrefs.AutoRecompilePartiallyUnsupportedChanges = true;
|
||||
HotReloadPrefs.DisplayNewMonobehaviourMethodsAsPartiallySupported = true;
|
||||
HotReloadRunTab.RecompileWithChecks();
|
||||
}
|
||||
GUILayout.FlexibleSpace();
|
||||
if (GUILayout.Button(" Don't show again ")) {
|
||||
if (GUILayout.Button(Translations.Suggestions.ButtonDontShowAgain)) {
|
||||
SetSuggestionsShown(HotReloadSuggestionKind.AddMonobehaviourMethod);
|
||||
SetSuggestionInactive(HotReloadSuggestionKind.AddMonobehaviourMethod);
|
||||
}
|
||||
@@ -376,12 +385,12 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
{ HotReloadSuggestionKind.SwitchToDebugModeForInlinedMethods, new AlertEntry(
|
||||
AlertType.Suggestion,
|
||||
"Switch code optimization to Debug Mode",
|
||||
"In Release Mode some methods are inlined, which prevents Hot Reload from applying changes. A clear warning is always shown when this happens, but you can use Debug Mode to avoid the issue altogether",
|
||||
Translations.Suggestions.SwitchToDebugModeTitle,
|
||||
Translations.Suggestions.SwitchToDebugModeMessage,
|
||||
actionData: () => {
|
||||
GUILayout.Space(10f);
|
||||
using (new EditorGUILayout.HorizontalScope()) {
|
||||
if (GUILayout.Button(" Switch to Debug mode ") && HotReloadRunTab.ConfirmExitPlaymode("Switching code optimization will stop Play Mode.\n\nDo you wish to proceed?")) {
|
||||
if (GUILayout.Button(Translations.Suggestions.ButtonSwitchToDebugMode) && HotReloadRunTab.ConfirmExitPlaymode(Translations.Suggestions.SwitchToDebugModeConfirmation)) {
|
||||
HotReloadRunTab.SwitchToDebugMode();
|
||||
}
|
||||
GUILayout.FlexibleSpace();
|
||||
@@ -394,18 +403,18 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
#endif
|
||||
{ HotReloadSuggestionKind.HotReloadWhileDebuggerIsAttached, new AlertEntry(
|
||||
AlertType.Suggestion,
|
||||
"Hot Reload is disabled while a debugger is attached",
|
||||
"Hot Reload automatically disables itself while a debugger is attached, as it can otherwise interfere with certain debugger features.\nWhile disabled, every code change will trigger a full Unity recompilation.\n\nYou can choose to keep Hot Reload enabled while a debugger is attached, though some features like debugger variable inspection might not always work as expected.",
|
||||
Translations.Suggestions.DebuggerAttachedTitle,
|
||||
Translations.Suggestions.DebuggerAttachedMessage,
|
||||
actionData: () => {
|
||||
GUILayout.Space(8f);
|
||||
using (new EditorGUILayout.HorizontalScope()) {
|
||||
if (GUILayout.Button(" Keep enabled during debugging ")) {
|
||||
if (GUILayout.Button(Translations.Suggestions.ButtonKeepEnabledDuringDebugging)) {
|
||||
SetSuggestionInactive(HotReloadSuggestionKind.HotReloadWhileDebuggerIsAttached);
|
||||
HotReloadPrefs.AutoDisableHotReloadWithDebugger = false;
|
||||
}
|
||||
GUILayout.FlexibleSpace();
|
||||
debuggerDocumentationButton.OnGUI();
|
||||
if (GUILayout.Button(" Don't show again ")) {
|
||||
if (GUILayout.Button(Translations.Suggestions.ButtonDontShowAgain)) {
|
||||
SetSuggestionsShown(HotReloadSuggestionKind.HotReloadWhileDebuggerIsAttached);
|
||||
SetSuggestionInactive(HotReloadSuggestionKind.HotReloadWhileDebuggerIsAttached);
|
||||
}
|
||||
@@ -417,14 +426,14 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
)},
|
||||
{ HotReloadSuggestionKind.HotReloadedMethodsWhenDebuggerIsAttached, new AlertEntry(
|
||||
AlertType.Suggestion,
|
||||
"Hot Reload may interfere with your debugger session",
|
||||
"Some debugger features, like variable inspection, might not work as expected for methods patched during the Hot Reload session. A full Unity recompile is required to get the full debugger experience.",
|
||||
Translations.Suggestions.DebuggerMethodsTitle,
|
||||
Translations.Suggestions.DebuggerMethodsMessage,
|
||||
actionData: () => {
|
||||
GUILayout.Space(8f);
|
||||
using (new EditorGUILayout.HorizontalScope()) {
|
||||
if (GUILayout.Button(" Recompile ")) {
|
||||
if (GUILayout.Button(Translations.Suggestions.ButtonRecompile)) {
|
||||
SetSuggestionInactive(HotReloadSuggestionKind.HotReloadedMethodsWhenDebuggerIsAttached);
|
||||
if (HotReloadRunTab.ConfirmExitPlaymode("Using the Recompile button will stop Play Mode.\n\nDo you wish to proceed?")) {
|
||||
if (HotReloadRunTab.ConfirmExitPlaymode(Translations.Suggestions.DebuggerMethodsConfirmation)) {
|
||||
HotReloadRunTab.Recompile();
|
||||
}
|
||||
}
|
||||
@@ -516,17 +525,11 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
private static async Task CheckEditorsWithoutHRAsync() {
|
||||
try {
|
||||
checkingEditorsWihtoutHR = true;
|
||||
var showSuggestion = await Task.Run(() => {
|
||||
try {
|
||||
var runningUnities = Process.GetProcessesByName("Unity Editor").Length;
|
||||
var runningPatchers = Process.GetProcessesByName("CodePatcherCLI").Length;
|
||||
return runningPatchers > 0 && runningUnities > runningPatchers;
|
||||
} catch (ArgumentException) {
|
||||
// On some devices GetProcessesByName throws ArgumentException for no good reason.
|
||||
// it happens rarely and the feature is not the most important so proper solution is not required
|
||||
return false;
|
||||
}
|
||||
});
|
||||
var editorsWithoutHr = await RequestHelper.RequestEditorsWithoutHRRunning();
|
||||
if (editorsWithoutHr == null) {
|
||||
return;
|
||||
}
|
||||
var showSuggestion = editorsWithoutHr.editorsWithoutHRRunning;
|
||||
if (!showSuggestion) {
|
||||
HotReloadSuggestionsHelper.SetSuggestionInactive(HotReloadSuggestionKind.EditorsWithoutHRRunning);
|
||||
return;
|
||||
|
||||
@@ -5,10 +5,11 @@ using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using JetBrains.Annotations;
|
||||
using SingularityGroup.HotReload.DTO;
|
||||
using SingularityGroup.HotReload.Localization;
|
||||
using SingularityGroup.HotReload.Newtonsoft.Json;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
using Translations = SingularityGroup.HotReload.Editor.Localization.Translations;
|
||||
|
||||
namespace SingularityGroup.HotReload.Editor {
|
||||
internal enum TimelineType {
|
||||
@@ -152,7 +153,7 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.Warning($"Failed initializing Hot Reload event entries on start: {e}");
|
||||
Log.Warning(Translations.Errors.WarningInitializingEventEntries, e);
|
||||
} finally {
|
||||
// Ensure red dot is not triggered for existing entries
|
||||
HotReloadState.ShowingRedDot = redDotShown;
|
||||
@@ -168,7 +169,7 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
try {
|
||||
File.WriteAllText(path: filePath, contents: JsonConvert.SerializeObject(persistedData));
|
||||
} catch (Exception e) {
|
||||
Log.Warning($"Failed persisting Hot Reload event entries: {e}");
|
||||
Log.Warning(Translations.Errors.WarningPersistingEventEntries, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,20 +192,20 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
};
|
||||
|
||||
#pragma warning disable CS0612 // obsolete
|
||||
public static Dictionary<PartiallySupportedChange, string> partiallySupportedChangeDescriptions = new Dictionary<PartiallySupportedChange, string> {
|
||||
{PartiallySupportedChange.LambdaClosure, "A lambda closure was edited (captured variable was added or removed). Changes to it will only be visible to the next created lambda(s)."},
|
||||
{PartiallySupportedChange.EditAsyncMethod, "An async method was edited. Changes to it will only be visible the next time this method is called."},
|
||||
{PartiallySupportedChange.AddMonobehaviourMethod, "A new method was added. It will not show up in the Inspector until the next full recompilation."},
|
||||
{PartiallySupportedChange.EditMonobehaviourField, "A field in a MonoBehaviour was removed or reordered. The inspector will not notice this change until the next full recompilation."},
|
||||
{PartiallySupportedChange.EditCoroutine, "An IEnumerator/IEnumerable was edited. When used as a coroutine, changes to it will only be visible the next time the coroutine is created."},
|
||||
{PartiallySupportedChange.EditGenericFieldInitializer, "A field initializer inside generic class was edited. Field initializer will not have any effect until the next full recompilation."},
|
||||
{PartiallySupportedChange.AddEnumMember, "An enum member was added. ToString and other reflection methods work only after the next full recompilation. Additionally, changes to the enum order may not apply until you patch usages in other places of the code."},
|
||||
{PartiallySupportedChange.EditFieldInitializer, "A field initializer was edited. Changes will only apply to new instances of that type, since the initializer for an object only runs when it is created."},
|
||||
{PartiallySupportedChange.AddMethodWithAttributes, "A method with attributes was added. Method attributes will not have any effect until the next full recompilation."},
|
||||
{PartiallySupportedChange.AddFieldWithAttributes, "A field with attributes was added. Field attributes will not have any effect until the next full recompilation."},
|
||||
{PartiallySupportedChange.GenericMethodInGenericClass, "A generic method was edited. Usages in non-generic classes applied, but usages in the generic classes are not supported."},
|
||||
{PartiallySupportedChange.NewCustomSerializableField, "A new custom serializable field was added. The inspector will not notice this change until the next full recompilation."},
|
||||
{PartiallySupportedChange.MultipleFieldsEditedInTheSameType, "Multiple fields modified in the same type during a single patch. Their values have been reset."},
|
||||
public static Dictionary<PartiallySupportedChange, string> partiallySupportedChangeDescriptions => new Dictionary<PartiallySupportedChange, string> {
|
||||
{PartiallySupportedChange.LambdaClosure, Translations.Timeline.PartiallySupportedLambdaClosure},
|
||||
{PartiallySupportedChange.EditAsyncMethod, Translations.Timeline.PartiallySupportedEditAsyncMethod},
|
||||
{PartiallySupportedChange.AddMonobehaviourMethod, Translations.Timeline.PartiallySupportedAddMonobehaviourMethod},
|
||||
{PartiallySupportedChange.EditMonobehaviourField, Translations.Timeline.PartiallySupportedEditMonobehaviourField},
|
||||
{PartiallySupportedChange.EditCoroutine, Translations.Timeline.PartiallySupportedEditCoroutine},
|
||||
{PartiallySupportedChange.EditGenericFieldInitializer, Translations.Timeline.PartiallySupportedEditGenericFieldInitializer},
|
||||
{PartiallySupportedChange.AddEnumMember, Translations.Timeline.PartiallySupportedAddEnumMember},
|
||||
{PartiallySupportedChange.EditFieldInitializer, Translations.Timeline.PartiallySupportedEditFieldInitializer},
|
||||
{PartiallySupportedChange.AddMethodWithAttributes, Translations.Timeline.PartiallySupportedAddMethodWithAttributes},
|
||||
{PartiallySupportedChange.AddFieldWithAttributes, Translations.Timeline.PartiallySupportedAddFieldWithAttributes},
|
||||
{PartiallySupportedChange.GenericMethodInGenericClass, Translations.Timeline.PartiallySupportedGenericMethodInGenericClass},
|
||||
{PartiallySupportedChange.NewCustomSerializableField, Translations.Timeline.PartiallySupportedNewCustomSerializableField},
|
||||
{PartiallySupportedChange.MultipleFieldsEditedInTheSameType, Translations.Timeline.PartiallySupportedMultipleFieldsEditedInTheSameType},
|
||||
};
|
||||
#pragma warning restore CS0612
|
||||
|
||||
@@ -215,7 +216,7 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
internal static int CompileErrorsCount => EventsTimeline.Count(alert => alert.alertType == AlertType.CompileError);
|
||||
internal static int AppliedChangesCount => EventsTimeline.Count(alert => alert.alertType == AlertType.AppliedChange);
|
||||
|
||||
static Regex shortDescriptionRegex = new Regex(@"^(\w+)\s(\w+)(?=:)", RegexOptions.Compiled);
|
||||
static Regex shortDescriptionRegex = new Regex(PackageConst.DefaultLocale == Locale.SimplifiedChinese ? @"^([\p{L}\p{N}_]+)\s([\p{L}\p{N}_]+)(?=:)" : @"^(\w+)\s(\w+)(?=:)", RegexOptions.Compiled);
|
||||
|
||||
internal static int GetRunTabTimelineEventCount() {
|
||||
int total = 0;
|
||||
@@ -240,7 +241,7 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
internal static List<AlertEntry> expandedEntries = new List<AlertEntry>();
|
||||
|
||||
internal static void RenderCompileButton() {
|
||||
if (GUILayout.Button("Recompile", GUILayout.Width(80))) {
|
||||
if (GUILayout.Button(Translations.Common.ButtonRecompile.Trim(), GUILayout.Width(80))) {
|
||||
HotReloadRunTab.RecompileWithChecks();
|
||||
}
|
||||
}
|
||||
@@ -330,8 +331,8 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
? AlertType.CompileError
|
||||
: AlertType.UnsupportedChange;
|
||||
var title = errorString.Contains("error CS")
|
||||
? "Compile error"
|
||||
: "Unsupported change";
|
||||
? Translations.Utility.CompileError
|
||||
: Translations.Utility.UnsupportedChange;
|
||||
ErrorData errorData = ErrorData.GetErrorData(errorString);
|
||||
var description = errorData.error;
|
||||
string shortDescription = null;
|
||||
@@ -363,8 +364,8 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
var entry = new AlertEntry(
|
||||
timestamp: timestamp,
|
||||
alertType : AlertType.UnsupportedChange,
|
||||
title: "Failed applying patch to method",
|
||||
description: $"Some methods got inlined by the Unity compiler and cannot be patched by Hot Reload. Switch to Debug mode to avoid this problem.\n\n• {(truncated ? patchesList + "\n..." : patchesList)}",
|
||||
title: Translations.Timeline.EventTitleFailedApplyingPatch,
|
||||
description: $"{Translations.Timeline.EventDescriptionInlinedMethods}\n\n• {(truncated ? patchesList + "\n..." : patchesList)}",
|
||||
entryType: EntryType.Parent,
|
||||
actionData: () => {
|
||||
GUILayout.Space(10f);
|
||||
@@ -388,13 +389,13 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
internal static void CreatePatchFailureEventEntry(string errorString, string methodName, string methodSimpleName = null, EntryType entryType = EntryType.Standalone, DateTime? createdAt = null) {
|
||||
var timestamp = createdAt ?? DateTime.Now;
|
||||
ErrorData errorData = ErrorData.GetErrorData(errorString);
|
||||
var title = $"Failed applying patch to method";
|
||||
var title = Translations.Timeline.EventTitleFailedApplyingPatch;
|
||||
Action actionData = () => RenderErrorEventActions(errorData.error, errorData);
|
||||
InsertEntry(new AlertEntry(
|
||||
timestamp: timestamp,
|
||||
alertType : AlertType.UnsupportedChange,
|
||||
title: title,
|
||||
description: $"{title}: {methodName}, tap here to see more.",
|
||||
description: string.Format(Translations.Timeline.EventDescriptionFailedApplyingPatchTapForMore, title, methodName),
|
||||
shortDescription: methodSimpleName,
|
||||
actionData: actionData,
|
||||
entryType: entryType,
|
||||
@@ -430,7 +431,7 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
title: EditorIndicationState.IndicationText[EditorIndicationState.IndicationStatus.Reloaded],
|
||||
description: patchedMethodsDisplayNames?.Length > 0
|
||||
? $"• {(truncated ? patchesList + "\n..." : patchesList)}"
|
||||
: "No issues found",
|
||||
: Translations.Timeline.EventDescriptionNoIssuesFound,
|
||||
entryType: patchedMethodsDisplayNames?.Length > 0 ? EntryType.Parent : EntryType.Standalone,
|
||||
alertData: new AlertData(
|
||||
AlertEntryType.PatchApplied,
|
||||
@@ -457,7 +458,7 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
timestamp: timestamp,
|
||||
alertType: AlertType.UnsupportedChange,
|
||||
title: EditorIndicationState.IndicationText[EditorIndicationState.IndicationStatus.Unsupported],
|
||||
description: patchedMembersDisplayNames?.Length > 0 ? $"• {(truncated ? patchesList + "\n...\n\nSee unsupported changes below" : patchesList + "\n\nSee unsupported changes below")}" : "See detailed entries below",
|
||||
description: patchedMembersDisplayNames?.Length > 0 ? $"• {(truncated ? patchesList + "\n...\n\n" + Translations.Timeline.EventDescriptionSeeUnsupportedChangesBelow : patchesList + "\n\n" + Translations.Timeline.EventDescriptionSeeUnsupportedChangesBelow)}" : Translations.Timeline.EventDescriptionSeeDetailedEntriesBelow,
|
||||
entryType: EntryType.Parent,
|
||||
alertData: new AlertData(AlertEntryType.Failure, createdAt: timestamp, entryType: EntryType.Parent, patchedMembersDisplayNames: patchedMembersDisplayNames)
|
||||
);
|
||||
@@ -479,7 +480,7 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
timestamp: timestamp,
|
||||
alertType: AlertType.PartiallySupportedChange,
|
||||
title: EditorIndicationState.IndicationText[EditorIndicationState.IndicationStatus.PartiallySupported],
|
||||
description: patchedMethodsDisplayNames?.Length > 0 ? $"• {(truncated ? patchesList + "\n...\n\nSee partially applied changes below" : patchesList + "\n\nSee partially applied changes below")}" : "See detailed entries below",
|
||||
description: patchedMethodsDisplayNames?.Length > 0 ? $"• {(truncated ? patchesList + "\n...\n\n" + Translations.Timeline.EventDescriptionSeePartiallyAppliedChangesBelow : patchesList + "\n\n" + Translations.Timeline.EventDescriptionSeePartiallyAppliedChangesBelow)}" : Translations.Timeline.EventDescriptionSeeDetailedEntriesBelow,
|
||||
entryType: EntryType.Parent,
|
||||
alertData: new AlertData(AlertEntryType.PartiallySupportedChange, createdAt: timestamp, entryType: EntryType.Parent, patchedMembersDisplayNames: patchedMethodsDisplayNames)
|
||||
);
|
||||
@@ -495,14 +496,13 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
timestamp: timestamp,
|
||||
alertType : AlertType.UndetectedChange,
|
||||
title: EditorIndicationState.IndicationText[EditorIndicationState.IndicationStatus.Undetected],
|
||||
description: "Code semantics didn't change (e.g. whitespace) or the change requires manual recompile.\n\n" +
|
||||
"Recompile to force-apply changes.",
|
||||
description: Translations.Timeline.EventDescriptionUndetectedChange,
|
||||
actionData: () => {
|
||||
GUILayout.Space(10f);
|
||||
using (new EditorGUILayout.HorizontalScope()) {
|
||||
RenderCompileButton();
|
||||
GUILayout.FlexibleSpace();
|
||||
OpenURLButton.Render("Docs", Constants.UndetectedChangesURL);
|
||||
OpenURLButton.Render(Translations.Suggestions.ButtonDocs, Constants.UndetectedChangesURL);
|
||||
GUILayout.Space(10f);
|
||||
}
|
||||
},
|
||||
@@ -520,7 +520,7 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
InsertEntry(new AlertEntry(
|
||||
timestamp: timestamp,
|
||||
alertType : AlertType.PartiallySupportedChange,
|
||||
title : detailed ? "Change partially applied" : ToString(partiallySupportedChange),
|
||||
title : detailed ? Translations.Timeline.EventTitleChangePartiallyApplied : ToString(partiallySupportedChange),
|
||||
description : description,
|
||||
shortDescription: detailed ? ToString(partiallySupportedChange) : null,
|
||||
actionData: () => {
|
||||
@@ -529,7 +529,7 @@ namespace SingularityGroup.HotReload.Editor {
|
||||
RenderCompileButton();
|
||||
GUILayout.FlexibleSpace();
|
||||
if (GetPartiallySupportedChangePref(partiallySupportedChange)) {
|
||||
if (GUILayout.Button("Ignore this event type ", HotReloadWindowStyles.LinkStyle)) {
|
||||
if (GUILayout.Button(Translations.Timeline.ButtonIgnoreEventType, HotReloadWindowStyles.LinkStyle)) {
|
||||
HidePartiallySupportedChange(partiallySupportedChange);
|
||||
HotReloadRunTab.RepaintInstant();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user