How to check if UI button has been clicked?

So basically, I have this foreach loop. The purpose of this foreach loop is to loop through each player in the player party, because each player has their own button. Let’s say I already have a reference to the button that is supposed to be clicked. How do I make the loop only move to the next item once the button has been pressed?

Should I just use an if/else-if or a switch statement instead?

Instead of waiting in a for loop you can subscribe a method to the Button’s clicked event that will message your state to move onto the next character.

This will make your code more modular and event driven. The latter means (generally) that there will be less cycles taken up by the operation as it will only be checked when neeeded.