Add support for changing scenes via Editor during play mode

This commit is contained in:
Wojtek Figat
2021-08-10 16:32:24 +02:00
parent 3115643397
commit 9a522615e5
2 changed files with 26 additions and 0 deletions

View File

@@ -251,6 +251,15 @@ namespace FlaxEditor.Modules
if (!Editor.StateMachine.CurrentState.CanChangeScene)
return;
// In play-mode Editor mocks the level streaming script
if (Editor.IsPlayMode)
{
if (!additive)
Level.UnloadAllScenesAsync();
Level.LoadSceneAsync(sceneId);
return;
}
if (!additive)
{
// Ensure to save all pending changes
@@ -272,6 +281,13 @@ namespace FlaxEditor.Modules
if (!Editor.StateMachine.CurrentState.CanChangeScene)
return;
// In play-mode Editor mocks the level streaming script
if (Editor.IsPlayMode)
{
Level.UnloadSceneAsync(scene);
return;
}
// Ensure to save all pending changes
if (CheckSaveBeforeClose())
return;
@@ -289,6 +305,13 @@ namespace FlaxEditor.Modules
if (!Editor.StateMachine.CurrentState.CanChangeScene)
return;
// In play-mode Editor mocks the level streaming script
if (Editor.IsPlayMode)
{
Level.UnloadAllScenesAsync();
return;
}
// Ensure to save all pending changes
if (CheckSaveBeforeClose())
return;

View File

@@ -28,6 +28,9 @@ namespace FlaxEditor.States
/// <inheritdoc />
public override bool CanEditScene => true;
/// <inheritdoc />
public override bool CanChangeScene => true;
/// <inheritdoc />
public override bool CanUseUndoRedo => false;