fix: Add null checks for MainMenuUI_T and TopLevelUICanvas in ServerBrowser to prevent instantiation errors
This commit is contained in:
@@ -299,7 +299,20 @@ namespace KCM
|
|||||||
|
|
||||||
try
|
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++)
|
for (int i = 0; i < kcmUICanvas.transform.childCount; i++)
|
||||||
Destroy(kcmUICanvas.transform.GetChild(i).gameObject);
|
Destroy(kcmUICanvas.transform.GetChild(i).gameObject);
|
||||||
|
|||||||
Reference in New Issue
Block a user