Optimize UI code

This commit is contained in:
Wojtek Figat
2025-03-16 23:07:56 +01:00
parent cd4ace3f49
commit 54050685d7
3 changed files with 6 additions and 7 deletions

View File

@@ -122,8 +122,6 @@ namespace FlaxEngine.GUI
if (_parent == value) if (_parent == value)
return; return;
Defocus();
Float2 oldParentSize; Float2 oldParentSize;
if (_parent != null) if (_parent != null)
{ {

View File

@@ -23,11 +23,11 @@ MMethod* UICanvas_EndPlay = nullptr;
MMethod* UICanvas_ParentChanged = nullptr; MMethod* UICanvas_ParentChanged = nullptr;
#define UICANVAS_INVOKE(event) \ #define UICANVAS_INVOKE(event) \
auto instance = GetManagedInstance(); \ auto* managed = GetManagedInstance(); \
if (instance) \ if (managed) \
{ \ { \
MObject* exception = nullptr; \ MObject* exception = nullptr; \
UICanvas_##event->Invoke(instance, nullptr, &exception); \ UICanvas_##event->Invoke(managed, nullptr, &exception); \
if (exception) \ if (exception) \
{ \ { \
MException ex(exception); \ MException ex(exception); \

View File

@@ -22,10 +22,11 @@ MMethod* UIControl_BeginPlay = nullptr;
MMethod* UIControl_EndPlay = nullptr; MMethod* UIControl_EndPlay = nullptr;
#define UICONTROL_INVOKE(event) \ #define UICONTROL_INVOKE(event) \
if (HasManagedInstance()) \ auto* managed = GetManagedInstance(); \
if (managed) \
{ \ { \
MObject* exception = nullptr; \ MObject* exception = nullptr; \
UIControl_##event->Invoke(GetManagedInstance(), nullptr, &exception); \ UIControl_##event->Invoke(managed, nullptr, &exception); \
if (exception) \ if (exception) \
{ \ { \
MException ex(exception); \ MException ex(exception); \