From 3dd611423eb5d3c8a673015c964ccbb0cfceac6f Mon Sep 17 00:00:00 2001 From: Konstantin Dyachenko Date: Wed, 27 May 2026 04:54:53 +0700 Subject: [PATCH] =?UTF-8?q?=EF=BB=BFfix:=20add=20null=20safety=20checks=20?= =?UTF-8?q?to=20UIView=20lifecycle=20methods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add this == null guard in Initialize() to prevent NullReferenceException after MonoBehaviour destruction - Add this == null guard in Release() for consistent safety across lifecycle methods - Prevent crashes when UI views are accessed during or after object destruction Исправлена безопасность при работе с UIView: - Добавлена проверка this == null в Initialize() для предотвращения NullReferenceException после уничтожения MonoBehaviour - Добавлена проверка this == null в Release() для согласованной безопасности во всех методах жизненного цикла - Предотвращены краши при обращении к UI видам во время или после разрушения объектов --- Assets/Scripts/Common/UI/UIView.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Assets/Scripts/Common/UI/UIView.cs b/Assets/Scripts/Common/UI/UIView.cs index 3476783..bfd39c0 100644 --- a/Assets/Scripts/Common/UI/UIView.cs +++ b/Assets/Scripts/Common/UI/UIView.cs @@ -8,6 +8,11 @@ namespace QuizPleaseTest.Common.UI public virtual void Initialize() { + if (this == null) + { + return; + } + if (_isInitialized) { return; @@ -19,6 +24,11 @@ namespace QuizPleaseTest.Common.UI public virtual void Release() { + if (this == null) + { + return; + } + if (!_isInitialized) { return;