From 845da14e6aabd6641dbd0fce5e137ae885996dd4 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 18 Mar 2021 10:56:48 +0100 Subject: [PATCH] Fix UIControl setup on IsActive changes #326 --- Source/Engine/UI/UIControl.cpp | 4 ++-- Source/Engine/UI/UIControl.cs | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/Engine/UI/UIControl.cpp b/Source/Engine/UI/UIControl.cpp index 106e51d63..6c24be02f 100644 --- a/Source/Engine/UI/UIControl.cpp +++ b/Source/Engine/UI/UIControl.cpp @@ -195,8 +195,8 @@ void UIControl::OnOrderInParentChanged() void UIControl::OnActiveInTreeChanged() { + UICONTROL_INVOKE(ActiveInTreeChanged); + // Base Actor::OnActiveInTreeChanged(); - - UICONTROL_INVOKE(ActiveInTreeChanged); } diff --git a/Source/Engine/UI/UIControl.cs b/Source/Engine/UI/UIControl.cs index 04194cf69..b8f8b00dd 100644 --- a/Source/Engine/UI/UIControl.cs +++ b/Source/Engine/UI/UIControl.cs @@ -328,6 +328,12 @@ namespace FlaxEngine { if (_control != null && !_blockEvents) { + // Skip if this control is inactive and it's parent too (parent will unlink from hierarchy but children will stay connected while being inactive) + if (!IsActiveInHierarchy && Parent && !Parent.IsActive) + { + return; + } + // Link or unlink control (won't modify Enable/Visible state) _control.Parent = GetParent(); _control.IndexInParent = OrderInParent;