Fix scripts reload to auto-save any modified assets in editor windows

This commit is contained in:
Wojtek Figat
2025-04-08 22:34:45 +02:00
parent 1ae098331d
commit c75b33eb7d
3 changed files with 7 additions and 2 deletions

View File

@@ -167,7 +167,7 @@ namespace FlaxEditor.Surface
bool hasTypeFromGameScripts = Editor.Instance.CodeEditing.AnimGraphNodes.HasTypeFromGameScripts;
// Check any surface parameter comes from Game scripts module to handle scripts reloads in Editor
if (!hasTypeFromGameScripts)
if (!hasTypeFromGameScripts && RootContext != null)
{
foreach (var param in Parameters)
{

View File

@@ -317,7 +317,7 @@ namespace FlaxEditor.Viewport.Previews
private void OnScriptsReloadBegin()
{
// Prevent any crashes due to dangling references to anim events
_previewModel.ResetAnimation();
_previewModel?.ResetAnimation();
}
/// <inheritdoc />

View File

@@ -171,6 +171,11 @@ namespace FlaxEditor.Windows.Assets
{
if (!IsHidden)
{
if (IsEdited && _item != null)
{
Editor.Log($"Auto-saving local changes to asset '{_item.Path}' before reloading code");
Save();
}
Editor.Instance.Windows.AddToRestore(this);
Close();
}