diff --git a/Source/Editor/Modules/SceneEditingModule.cs b/Source/Editor/Modules/SceneEditingModule.cs index 9ffbc514f..7b28367ff 100644 --- a/Source/Editor/Modules/SceneEditingModule.cs +++ b/Source/Editor/Modules/SceneEditingModule.cs @@ -450,7 +450,13 @@ namespace FlaxEditor.Modules SelectionDeleteEnd?.Invoke(); if (isSceneTreeFocus) + { Editor.Windows.SceneWin.Focus(); + } + + // fix scene window layout + Editor.Windows.SceneWin.PerformLayout(); + Editor.Windows.SceneWin.PerformLayout(); } /// @@ -514,6 +520,9 @@ namespace FlaxEditor.Modules Undo.AddAction(new MultiUndoAction(pasteAction, selectAction)); OnSelectionChanged(); } + + // Scroll to new selected node while pasting + Editor.Windows.SceneWin.ScrollToSelectedNode(); } /// @@ -611,6 +620,9 @@ namespace FlaxEditor.Modules Undo.AddAction(new MultiUndoAction(undoActions)); OnSelectionChanged(); } + + // Scroll to new selected node while duplicating + Editor.Windows.SceneWin.ScrollToSelectedNode(); } /// diff --git a/Source/Editor/Windows/SceneTreeWindow.cs b/Source/Editor/Windows/SceneTreeWindow.cs index b0bed2002..396bd3747 100644 --- a/Source/Editor/Windows/SceneTreeWindow.cs +++ b/Source/Editor/Windows/SceneTreeWindow.cs @@ -210,6 +210,20 @@ namespace FlaxEditor.Windows _sceneTreePanel.HScrollBar.ThumbEnabled = enabled; } + /// + /// Scrolls to the selected node in the scene tree. + /// + public void ScrollToSelectedNode() + { + // Scroll to node + var nodeSelection = _tree.Selection; + if (nodeSelection.Count != 0) + { + var scrollControl = nodeSelection[nodeSelection.Count - 1]; + _sceneTreePanel.ScrollViewTo(scrollControl); + } + } + private void OnSearchBoxTextChanged() { // Skip events during setup or init stuff diff --git a/Source/Engine/Graphics/GPUDevice.cpp b/Source/Engine/Graphics/GPUDevice.cpp index 6a77fe858..b9f1aeba2 100644 --- a/Source/Engine/Graphics/GPUDevice.cpp +++ b/Source/Engine/Graphics/GPUDevice.cpp @@ -3,6 +3,7 @@ #include "GPUDevice.h" #include "RenderTargetPool.h" #include "GPUPipelineState.h" +#include "GPUSwapChain.h" #include "RenderTask.h" #include "RenderTools.h" #include "Graphics.h" @@ -12,7 +13,6 @@ #include "Engine/Content/Assets/Material.h" #include "Engine/Content/Content.h" #include "Engine/Content/SoftAssetReference.h" -#include "Engine/Platform/Windows/WindowsWindow.h" #include "Engine/Render2D/Render2D.h" #include "Engine/Engine/CommandLine.h" #include "Engine/Engine/Engine.h" @@ -408,7 +408,7 @@ void GPUDevice::DrawEnd() for (int32 i = RenderTask::Tasks.Count() - 1; i >= 0; i--) { const auto task = RenderTask::Tasks[i]; - if (task && task->LastUsedFrame == Engine::FrameCount && task->SwapChain) + if (task && task->LastUsedFrame == Engine::FrameCount && task->SwapChain && task->SwapChain->IsReady()) { lastWindowIndex = i; break; @@ -421,7 +421,7 @@ void GPUDevice::DrawEnd() for (int32 i = 0; i < RenderTask::Tasks.Count(); i++) { const auto task = RenderTask::Tasks[i]; - if (task && task->LastUsedFrame == Engine::FrameCount && task->SwapChain) + if (task && task->LastUsedFrame == Engine::FrameCount && task->SwapChain && task->SwapChain->IsReady()) { bool vsync = useVSync; if (lastWindowIndex != i)