Fix ScreenSpace UICanvas order in Prefab preview (move back to prevent editor widgets occlusion)

This commit is contained in:
Wojtek Figat
2021-04-29 16:21:29 +02:00
parent eaa5716d6a
commit c996476a28

View File

@@ -428,7 +428,10 @@ namespace FlaxEngine
} }
#if FLAX_EDITOR #if FLAX_EDITOR
if (_editorRoot != null && IsActiveInHierarchy) if (_editorRoot != null && IsActiveInHierarchy)
{
_guiRoot.Parent = _editorRoot; _guiRoot.Parent = _editorRoot;
_guiRoot.IndexInParent = 0;
}
#endif #endif
if (_isRegisteredForTick) if (_isRegisteredForTick)
{ {
@@ -637,6 +640,7 @@ namespace FlaxEngine
if (RenderMode == CanvasRenderMode.ScreenSpace && _editorRoot != null && _guiRoot != null) if (RenderMode == CanvasRenderMode.ScreenSpace && _editorRoot != null && _guiRoot != null)
{ {
_guiRoot.Parent = HasParent && IsActiveInHierarchy ? _editorRoot : null; _guiRoot.Parent = HasParent && IsActiveInHierarchy ? _editorRoot : null;
_guiRoot.IndexInParent = 0;
} }
#endif #endif
} }
@@ -644,7 +648,15 @@ namespace FlaxEngine
internal void OnEnable() internal void OnEnable()
{ {
#if FLAX_EDITOR #if FLAX_EDITOR
_guiRoot.Parent = _editorRoot ?? RootControl.CanvasRoot; if (_editorRoot != null)
{
_guiRoot.Parent = _editorRoot;
_guiRoot.IndexInParent = 0;
}
else
{
_guiRoot.Parent = RootControl.CanvasRoot;
}
#else #else
_guiRoot.Parent = RootControl.CanvasRoot; _guiRoot.Parent = RootControl.CanvasRoot;
#endif #endif
@@ -677,7 +689,8 @@ namespace FlaxEngine
{ {
if (RenderMode == CanvasRenderMode.ScreenSpace && _editorRoot != null && _guiRoot != null) if (RenderMode == CanvasRenderMode.ScreenSpace && _editorRoot != null && _guiRoot != null)
{ {
_guiRoot.Parent = IsActiveInHierarchy ? _editorRoot : null; _guiRoot.Parent = HasParent && IsActiveInHierarchy ? _editorRoot : null;
_guiRoot.IndexInParent = 0;
} }
} }
#endif #endif
@@ -717,7 +730,10 @@ namespace FlaxEngine
Setup(); Setup();
if (RenderMode == CanvasRenderMode.ScreenSpace && _editorRoot != null && _guiRoot != null && IsActiveInHierarchy) if (RenderMode == CanvasRenderMode.ScreenSpace && _editorRoot != null && _guiRoot != null && IsActiveInHierarchy)
{
_guiRoot.Parent = _editorRoot; _guiRoot.Parent = _editorRoot;
_guiRoot.IndexInParent = 0;
}
} }
#endif #endif
} }