check bool in WaitForSeconds

Are there a method for check ture/false in the WaitForSeconds function?
When the boolean is changed and do something immediately

You must be changing boolean some where in your code, so at that place you can call any function and do something in there. I’m not getting your point why are you asking about waitforseconds, if you can elaborate your question may be i can help after that.

IEnumerator Example()
yield return new WaitUntil(yourBool);//this will wait UNTIL your bool is true
Debug.Log(“Your bool is true add here your code”);

   //if you need to make sure it only gets excuted during x amount of time add a timer

   int timer = 0;

   while(timer < 5)//will wait for 5 seconds
      if(yourBool)//if your bool is true break the while
         Debug.Log("Your bool is true add  here your code");
      timer += Time.deltaTime;
      yield return null;