Wait for button response in coroutine?

Since this is a quite common issue / task to wait for an UI button press in a coroutine, I just created a custom yield instruction that will handle this for you. I added it to the WaitForUIButtons wiki:

UI/WaitForUIButtons - Unify Community Wiki (archive.org)

Here’s also a pastebin backup of the script:
WaitForUIButtons.cs - Pastebin.com

You can provide it a list of UI buttons and this class will register temporary callbacks to all those buttons. When one of the buttons is pressed the internal PressedButton property will be set to the button that was pressed. So you can simply do:

// from my wiki examples
public Button yesButton;
public Button noButton;

IEnumerator Dialog()
{
    // ...
    var waitForButton = new WaitForUIButtons(yesButton, noButton);
    yield return waitForButton.Reset();
    if (waitForButton.PressedButton == yesButton)
    {
        // yes was pressed
    }
    else
    {
        // no was pressed
    }
    // ...
}