How can I dim light over time?

For a uni brief we have an exploration based game and i want to represent the vehicles fuel/energy, perhaps via a light that dims the longer the player has been out and about. Cant use guitextures, so a literal fuel bar is out of the question, this light dimming thing was best i came up with, and i’ve looked and not finding much.

Im guessings it’s got something to do with get.component, and the intensity of the light. any one able to help me out, or atleast point me in the right direction.

You can just set a timer and have check to see if time elapsed is equal to a set int.

Here is a quick way to do it, it will fade from awakening.

public class GasMeter
  public Light lightToDim = null;    
  public float maxTime = 30; //30 seconds

  private float mEndTime = 0;
  private float mStartTime = 0;

  private void Awake()
    mStartTime = Time.time;
    mEndTime= mStartTime + maxTime;

  private void Update()
      lightToDim.intensity = Mathf.InverseLerp(mStartTime, mEndTime, Time.time);