Fix editor play state exceptions into errors to prevent locking editor state

This commit is contained in:
Wojtek Figat
2024-05-30 17:26:43 +02:00
parent 949057b1c3
commit 806bff19f4
2 changed files with 22 additions and 9 deletions

View File

@@ -77,7 +77,6 @@ namespace FlaxEditor.States
{
if (!IsActive)
throw new InvalidOperationException();
Time.GamePaused = value;
}
}

View File

@@ -36,7 +36,10 @@ namespace FlaxEditor.Utilities
public void GatherSceneData()
{
if (HasData)
throw new InvalidOperationException("DuplicateScenes has already gathered scene data.");
{
Editor.LogError("DuplicateScenes has already gathered scene data.");
return;
}
Profiler.BeginEvent("DuplicateScenes.GatherSceneData");
Editor.Log("Collecting scene data");
@@ -47,7 +50,8 @@ namespace FlaxEditor.Utilities
if (scenesCount == 0)
{
Profiler.EndEvent();
throw new InvalidOperationException("Cannot gather scene data. No scene loaded.");
Editor.LogWarning("Cannot gather scene data. No scene loaded.");
return;
}
var sceneIds = new Guid[scenesCount];
for (int i = 0; i < scenesCount; i++)
@@ -72,7 +76,8 @@ namespace FlaxEditor.Utilities
if (Level.UnloadAllScenes())
{
Profiler.EndEvent();
throw new Exception("Failed to unload scenes.");
Editor.LogError("Failed to unload scenes.");
return;
}
FlaxEngine.Scripting.FlushRemovedObjects();
@@ -82,7 +87,8 @@ namespace FlaxEditor.Utilities
if (noScenes != null && noScenes.Length != 0)
{
Profiler.EndEvent();
throw new Exception("Failed to unload scenes.");
Editor.LogError("Failed to unload scenes.");
return;
}
}
@@ -96,7 +102,10 @@ namespace FlaxEditor.Utilities
public void CreateScenes()
{
if (!HasData)
throw new InvalidOperationException("DuplicateScenes has not gathered scene data yet.");
{
Editor.LogError("DuplicateScenes has not gathered scene data yet.");
return;
}
Profiler.BeginEvent("DuplicateScenes.CreateScenes");
Editor.Log("Creating scenes");
@@ -110,7 +119,8 @@ namespace FlaxEditor.Utilities
if (scene == null)
{
Profiler.EndEvent();
throw new Exception("Failed to deserialize scene");
Editor.LogError("Failed to deserialize scene.");
return;
}
}
@@ -131,7 +141,8 @@ namespace FlaxEditor.Utilities
if (Level.UnloadAllScenes())
{
Profiler.EndEvent();
throw new Exception("Failed to unload scenes.");
Editor.LogError("Failed to unload scenes.");
return;
}
FlaxEngine.Scripting.FlushRemovedObjects();
Editor.WipeOutLeftoverSceneObjects();
@@ -145,7 +156,10 @@ namespace FlaxEditor.Utilities
public void RestoreSceneData()
{
if (!HasData)
throw new InvalidOperationException("DuplicateScenes has not gathered scene data yet.");
{
Editor.LogError("DuplicateScenes has not gathered scene data yet.");
return;
}
Profiler.BeginEvent("DuplicateScenes.RestoreSceneData");
// Deserialize old scenes