title: Create a class/method for a time (start, reset, stop, get istant, get timerun)
body: <p>I'm building a racing game and I'm working on race times.</p>
  
  <p>I try to build a system to start an instance of a timer with various options.</p>
  
  <p>My little experience is putting me in crisis ... would some good soul want to help me?</p>
  
  <p>This was the idea:</p>
  
  <pre><code>public class Timer {
  
  
      public float counter;
      public bool reset; 
      public string runtime = "--:--:--";
      public string istant = "not istant";
  
      public void startTimer()
      {
  
          /* inupdatealternative: counter += Time.deltaTime; */
  
          if(reset == true)
          {
              counter = 0;
          }
          else
          {
              counter = Time.time;
          }
  
          var minutes = counter/60;               // divide guitime by sixty (minutes)
          var seconds = counter%60;               // euclidean division (seconds)
          var fraction = (counter * 100) % 100;   // get fraction of seconds
          runtime = string.Format ( "{0:00}:{1:00}:{2:000}", minutes, seconds, fraction);
  
          Debug.Log("in Start: "+runtime);
  
      }
  
      public void resetTimer()
      {
          reset = true;
      }
  
      public string getTimerRuntime()
      {
          return runtime;
      }
  
      public string getTimerIstant()
      {
          istant = runtime;
          return istant;
      }
  
  }
  </code></pre>
  
  <p>in update, for exemple:</p>
  
  <pre><code>var lapTimer = new Timer(); // create a new timer
  if(Lap &lt; Pilot.pilotlap )
  {
      lapTimer.startTimer();
      Lap++
  }
  else if(Lap==Pilot.pilotlap)
  {
      timerLabel.text = lapTimer.getTimerIstant();
      lapTimer.resetTimer();
      lapTimer.startTimer();
  }
  </code></pre>
  
  <p>in my head I'm sure someone has already dealt with it ... surely there will be something that manages the times and returns values ​​in various ways: does it exist? or is there anyway how to make or build such a thing?</p>