Execute IF statement once inside the Update Function?

I didn’t get an answer from the last question so now I am asking it in a more clear and straightforward manner.

So here is my script:

if(hunting == true)
    {

        //Displays Hunting Progress
        progressText.text = "% " + progress + " Complete";

        canRest = false;
        canHunt = false;

        //If progress = 100, Spawn furs.
        if(progress == 100)
        {
            CancelInvoke("consumeFood");
            CancelInvoke("increaseProgress");

            canRest = true;
            canHunt = true;

            
        
            if(level >= 1)
            {
                if(!singleExecution)
                {
                    SpawnFur();
                    singleExecution = true;
                }

            }
        }
    }

This currently in Update Function as it needs to check for “Progress” every frame. But when progress reaches 100, the if statement inside of it will be fired multiple times because it is in Update.

the current set up I have with the singleExecution bool allows it to be fired ONCE, that is all, as the bool will be cleared after the first execution.

However I only want it to be fired ONCE when the condition(Progress == 100) is met EVERY TIME. How do I do that? Any help would be appreciated.

Try number 2 then.

public bool canRunProgress = false; // Kind of like the singleExecution

if(hunting == true)
 {

     //Displays Hunting Progress
     progressText.text = "% " + progress + " Complete";

     canRest = false;
     canHunt = false;

     //If progress = 100, Spawn furs.
     if(progress == 100 && canRunProgress)
     {
         canRunProgress = false;  // Immediately stop this from running more than once.
         CancelInvoke("consumeFood");
         CancelInvoke("increaseProgress");

         canRest = true;
         canHunt = true;

         
     
         if(level >= 1)
         {
             if(!singleExecution)
             {
                 SpawnFur();
                 singleExecution = true;
             }

         }
     }
    else { 
        canRunProgress = true;   // Only when progress isn't 100 anymore can it run again.
    }
 }

Set up a bool within the if (progress == 100) line. Have something like;
if (progress == 100 && progressbool == true){
do stuff and set progressbool to false }
Then set up a later condition that sets the progressbool back to true once you’re certain it won’t fire the code again.

You’ll have to make a separate boolean variable that is initially set to false, and then set it to true in the code, (or the other way around). Then, modify the if statement so that it checks for the initial state of the boolean before executing the code. If needed, you can reset the boolean to false outside the code somewhere, but you may need another one-shot boolean for that too, and it might add up.

Separate question:
Is there a monobehaviour extension that can be made to handle these situations? I hate to declare so many boolean variables for all of the pieces of code that only need to run once in Update(). I would love to make a monobehaviour extension for this myself, but I really am not sure how.

You are checking if Progress is equal to 100, what you need to know is if 100 was reached. To know this you only need to know if it was previously not 100.

Put this at the top of your Update method. It makes sure that if progress is ever less than 100 then it resets the boolean so your code knows to re-execute SpawnFur() in a future call to Update() when progress does == 100

if (progress < 100) {
  singleExecute = false;
}