I have a button with a cooldown. How do I make it so the cooldown time increases with each press of the button?

Here is my code:

    {		
	    public GameObject Button;
		
	    public void Button()
    {
            ///stuff here...///
    }
	    Button.SetActive(false);
            Invoke("ButtonCooldown",0.8f);		
    }	
    }
    }
	
	    void ButtonCooldown()
    {      
            Button.SetActive(true);
    }
    }

Basically, I want it to be that every time you press the button, the time you have to wait before pressing it again increases by say, 0.2f. Right now it has a cooldown of 0.8f every time you press it.

How can I do this?

Hey Geoffrey, what you can do is keep the button cooldown value in a float variable and then add 0.2f to it every time your button has been cooled down.

For example, your modified code would be (untested):

         public GameObject Button;

         private float cooldownValue = 0.8f;
         
         public void Button()
     {
             ///stuff here...///
     }
         Button.SetActive(false);
             Invoke("ButtonCooldown", cooldownValue);        
     }    
     }
     }
     
         void ButtonCooldown()
     {      
             Button.SetActive(true);

             //Adds 0.2f to the current value of the button's cooldown value
             cooldownValue += 0.2f;
     }
     }

public float timeIncrease ;//enter your increase float here;

public float invokeTime = 0.8f;//Invoke Time

//Each time this method is called invoke time will increase
public void button(){
Invoke("ButtonCoolDown", invokeTime);
invokeTime += timeIncrease;

}