Add support for changing scenes via Editor during play mode
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user