Displaying a timer on a button.

Hey,

I’ve got a bunch of “attack” buttons which are created based on arrays. I’d like to display a countdown timer of sime kind on the button when it’s clicked. Does anyone have any idea how I would go about doing this? Here’s the code for the buttons:

if (GUILayout.Button(AttackNames, GUILayout.Width(60), GUILayout.Height(60))/* FocusController.currentFocus!=null*/ AttackCooldowns == false dist < AttackRange*){*
ApplyDamage(AttackDamage,AttackType_,AttackEffectTimes*);
AttackCooldowns=true;
delayInvoke(i);
}
}*_

Use Time.time and alter the display value based on the last attack time?

var lastAttack : float[];

function OnGUI() {
 var displayVal : float = attackCooldowns[i] - (Time.time - lastAttack[i] );
 if ( displayVal < 0.0 ) displayVal = 0.0;
 if (GUILayout.Button(AttackNames[i] + " : " + displayVal, GUILayout.Width(60), GUILayout.Height(60))  displayVal == 0.0  dist < attackRange[i] ) {
  lastAttack[i] = attackCooldowns[i];
 }
}