Wait for bool to be true then return

What I am trying to achive is this:

I have a script which is supposed to wait for a bool to be true but it doesn’t work.

	public static void Popup(string text) {
		instance.ShowPopup = true;
		instance.PopupText = text;
		while (!GiveTheManASignalForGodsSake) {
			yield return null;
		}
		if (GiveTheManASignalForGodsSake) {
			return true;
		}
	}

NOTE: I get this error with the code above:

error CS1624: The body of `Game.Popup(string)' cannot be an iterator block because `void' is not an iterator interface type

The ShowPopup variable is used in the OnGUI section to show some GUI, and when the player clicks yes it is supposed to return true so that the called can run the piece of code that it is supposed to do when the player clicks yes:

if (Game.Popup("Are you sure you want to login?")) { //So when the player has done the prompt it will run the code below:
	Login(Username, Md5Sum(Password));
}

The GUI Code:

void OnGUI() {
	if (ShowPopup) {
		rct = new Rect(Screen.width/2-125,Screen.height/2-100, 250, 200);
		GUI.Box(rct, PopupText);
		rct2 = new Rect(Screen.width/2-125,Screen.height/2, 125, 25);
		if (GUI.Button(rct2, "Yes")) {
			ShowPopup = false;
			GiveTheManASignalForGodsSake = true;
		}
		rct1 = new Rect(Screen.width/2,Screen.height/2, 125, 25);
		if (GUI.Button(rct1, "No")) {
			ShowPopup = false;
		}
	}
}

You cannot yield from inside a function that returns void.

You can only yield from within coroutines, and they have the return type IEnumerator and must be started with StartCoroutine();

See

You can run all your update stuff in here with the ability to wait for a boolean.

bool Yield;
IEnumerator Yielder ()
{
    while (Yield == true)
    {
        yield;
    }
    //Update stuff goes here
    yield return new WaitForSeconds(Time.deltaTime);
}

You could also just make a huge bracket around everything so the update only happens when the condition is met.

void Update()
{
if (!Yield)
{
//Update stuff goes here
}
}

but with this method you won’t be able to pause in the middle of the function.