From 5ffa3eb83731ea32d69339ff2bc2a6bf6861d414 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 4 Mar 2025 22:12:35 +0100 Subject: [PATCH] Fix getting Control from null ControlReference #3123 --- Source/Engine/UI/ControlReference.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/Engine/UI/ControlReference.cs b/Source/Engine/UI/ControlReference.cs index 0bcd54374..68f50fa23 100644 --- a/Source/Engine/UI/ControlReference.cs +++ b/Source/Engine/UI/ControlReference.cs @@ -43,9 +43,11 @@ namespace FlaxEngine { get { - if (_uiControl != null && _uiControl.Control is T t) + if (_uiControl == null) + return null; + if (_uiControl.Control is T t) return t; - Debug.Write(LogType.Warning, "Trying to get Control from ControlReference but UIControl is null, or UIControl.Control is null, or UIControl.Control is not the correct type."); + Debug.Write(LogType.Warning, "Trying to get Control from ControlReference but UIControl.Control is null, or the correct type."); return null; } } @@ -66,7 +68,7 @@ namespace FlaxEngine } else { - Debug.Write(LogType.Warning, "Trying to set ControlReference but UIControl.Control is null or UIControl.Control is not the correct type."); + Debug.Write(LogType.Warning, "Trying to set UIControl but UIControl.Control is null or not the correct type."); } } }