From 25f5af0b4d87064d1cb5de9a195eeb0718368f2c Mon Sep 17 00:00:00 2001 From: b3ni15 Date: Mon, 15 Dec 2025 09:40:11 +0100 Subject: [PATCH] fix: Add null checks for MainMenuUI_T and TopLevelUICanvas in ServerBrowser to prevent instantiation errors --- ServerBrowser/ServerBrowser.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ServerBrowser/ServerBrowser.cs b/ServerBrowser/ServerBrowser.cs index f37ebd8..c9d1a63 100644 --- a/ServerBrowser/ServerBrowser.cs +++ b/ServerBrowser/ServerBrowser.cs @@ -299,7 +299,20 @@ namespace KCM try { - GameObject kcmUICanvas = Instantiate(Constants.MainMenuUI_T.Find("TopLevelUICanvas").gameObject); + if (Constants.MainMenuUI_T == null) + { + Main.helper.Log("MainMenuUI_T is null in ServerBrowser"); + return; + } + + var topLevelCanvas = Constants.MainMenuUI_T.Find("TopLevelUICanvas"); + if (topLevelCanvas == null) + { + Main.helper.Log("TopLevelUICanvas not found in ServerBrowser"); + return; + } + + GameObject kcmUICanvas = Instantiate(topLevelCanvas.gameObject); for (int i = 0; i < kcmUICanvas.transform.childCount; i++) Destroy(kcmUICanvas.transform.GetChild(i).gameObject);