From 54050685d7ecf450f76bb3ef0fea8ddeb77c3dd2 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sun, 16 Mar 2025 23:07:56 +0100 Subject: [PATCH] Optimize UI code --- Source/Engine/UI/GUI/Control.cs | 2 -- Source/Engine/UI/UICanvas.cpp | 6 +++--- Source/Engine/UI/UIControl.cpp | 5 +++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Source/Engine/UI/GUI/Control.cs b/Source/Engine/UI/GUI/Control.cs index 53fdd5502..f88cae3a5 100644 --- a/Source/Engine/UI/GUI/Control.cs +++ b/Source/Engine/UI/GUI/Control.cs @@ -122,8 +122,6 @@ namespace FlaxEngine.GUI if (_parent == value) return; - Defocus(); - Float2 oldParentSize; if (_parent != null) { diff --git a/Source/Engine/UI/UICanvas.cpp b/Source/Engine/UI/UICanvas.cpp index a7af9c8c7..f0a2f25e7 100644 --- a/Source/Engine/UI/UICanvas.cpp +++ b/Source/Engine/UI/UICanvas.cpp @@ -23,11 +23,11 @@ MMethod* UICanvas_EndPlay = nullptr; MMethod* UICanvas_ParentChanged = nullptr; #define UICANVAS_INVOKE(event) \ - auto instance = GetManagedInstance(); \ - if (instance) \ + auto* managed = GetManagedInstance(); \ + if (managed) \ { \ MObject* exception = nullptr; \ - UICanvas_##event->Invoke(instance, nullptr, &exception); \ + UICanvas_##event->Invoke(managed, nullptr, &exception); \ if (exception) \ { \ MException ex(exception); \ diff --git a/Source/Engine/UI/UIControl.cpp b/Source/Engine/UI/UIControl.cpp index 72eed1f27..692843361 100644 --- a/Source/Engine/UI/UIControl.cpp +++ b/Source/Engine/UI/UIControl.cpp @@ -22,10 +22,11 @@ MMethod* UIControl_BeginPlay = nullptr; MMethod* UIControl_EndPlay = nullptr; #define UICONTROL_INVOKE(event) \ - if (HasManagedInstance()) \ + auto* managed = GetManagedInstance(); \ + if (managed) \ { \ MObject* exception = nullptr; \ - UIControl_##event->Invoke(GetManagedInstance(), nullptr, &exception); \ + UIControl_##event->Invoke(managed, nullptr, &exception); \ if (exception) \ { \ MException ex(exception); \