Fix error when switching to a screen without an inventory gui widget (#24059)

This commit is contained in:
DrSmugleaf
2024-01-13 19:18:28 -08:00
committed by GitHub
parent 8416fc746b
commit 6a7f1b2f1f

View File

@@ -57,8 +57,8 @@ public sealed class InventoryUIController : UIController, IOnStateEntered<Gamepl
if (UIManager.ActiveScreen == null)
return;
var inventoryGui = UIManager.GetActiveUIWidget<InventoryGui>();
RegisterInventoryButton(inventoryGui.InventoryButton);
if (UIManager.GetActiveUIWidgetOrNull<InventoryGui>() is { } inventoryGui)
RegisterInventoryButton(inventoryGui.InventoryButton);
}
public void OnStateEntered(GameplayState state)