From c996476a282a0d3c7432c823632cce1fa00e5cba Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 29 Apr 2021 16:21:29 +0200 Subject: [PATCH] Fix ScreenSpace UICanvas order in Prefab preview (move back to prevent editor widgets occlusion) --- Source/Engine/UI/UICanvas.cs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Source/Engine/UI/UICanvas.cs b/Source/Engine/UI/UICanvas.cs index 48dc36713..fdb413837 100644 --- a/Source/Engine/UI/UICanvas.cs +++ b/Source/Engine/UI/UICanvas.cs @@ -428,7 +428,10 @@ namespace FlaxEngine } #if FLAX_EDITOR if (_editorRoot != null && IsActiveInHierarchy) + { _guiRoot.Parent = _editorRoot; + _guiRoot.IndexInParent = 0; + } #endif if (_isRegisteredForTick) { @@ -637,6 +640,7 @@ namespace FlaxEngine if (RenderMode == CanvasRenderMode.ScreenSpace && _editorRoot != null && _guiRoot != null) { _guiRoot.Parent = HasParent && IsActiveInHierarchy ? _editorRoot : null; + _guiRoot.IndexInParent = 0; } #endif } @@ -644,7 +648,15 @@ namespace FlaxEngine internal void OnEnable() { #if FLAX_EDITOR - _guiRoot.Parent = _editorRoot ?? RootControl.CanvasRoot; + if (_editorRoot != null) + { + _guiRoot.Parent = _editorRoot; + _guiRoot.IndexInParent = 0; + } + else + { + _guiRoot.Parent = RootControl.CanvasRoot; + } #else _guiRoot.Parent = RootControl.CanvasRoot; #endif @@ -677,7 +689,8 @@ namespace FlaxEngine { if (RenderMode == CanvasRenderMode.ScreenSpace && _editorRoot != null && _guiRoot != null) { - _guiRoot.Parent = IsActiveInHierarchy ? _editorRoot : null; + _guiRoot.Parent = HasParent && IsActiveInHierarchy ? _editorRoot : null; + _guiRoot.IndexInParent = 0; } } #endif @@ -717,7 +730,10 @@ namespace FlaxEngine Setup(); if (RenderMode == CanvasRenderMode.ScreenSpace && _editorRoot != null && _guiRoot != null && IsActiveInHierarchy) + { _guiRoot.Parent = _editorRoot; + _guiRoot.IndexInParent = 0; + } } #endif }