more safety here

This commit is contained in:
minenice55 2023-12-02 20:20:13 -05:00
parent bdbc88d516
commit 0a8fa5a1aa

View file

@ -57,7 +57,7 @@ namespace HeavenStudio.Common
isPaused = true;
canPick = false;
optionSelected = 0;
ChooseOption((Options)optionSelected, false);
ChooseCurrentOption();
}
void UnPause(bool instant = false)
@ -130,10 +130,9 @@ namespace HeavenStudio.Common
{
foreach (Transform t in optionHolder.transform)
{
if (t.GetComponent<Collider2D>().OverlapPoint(PlayerInput.GetInputController(1).GetPointer()))
if (t.TryGetComponent<Collider2D>(out Collider2D c) && c.OverlapPoint(PlayerInput.GetInputController(1).GetPointer()))
{
int idx = t.GetSiblingIndex();
ChooseOption((Options)idx, idx != optionSelected);
optionSelected = idx;
break;
}