What would be the best approach for regenerating stats?

I’m scripting player stats and was wondering what would be the best approach for regenerating health/stamina/magic? what would be the easiest and/or what would be the most efficient?

Something like this?

float maxhealth = 100;       //maximum health
float curhealth = maxhealth; //current health

void SomeMethod(){
InvokeRepeating("RegenHealth", 1, 1);
}

void RegenHealth(){
if (curhealth < maxhealth){
     curhealth += 2;
}
if(curhealth >= maxhealth){
     curhealth = maxhealth;
     CancelInvoke();
}

Or something like this?

void Update(){
    if(curhealth < maxhealth){
         curhealth += 2 * Time.deltatime;
    
         if(curhealth >= maxhealth){
              curhealth = maxhealth;
              }
         }
}

Or is there another way of doing it? Answers appreciated.

Both versions work just fine. I’d say that the first method is what i would use, as you can add effects to it as well such as floating icons that say +2 over a health bar or what not. The second one is a bit easier to read and you have a finer granularity to how much health is being recovered. The player might only get back 1.5hp before they get attacked rather then a straight 2hp/sec.

All in all they both work great and both have there pro/cons.