Changing timer colour over time

So I have a simple timer that displays on the screen:

void OnGUI ()
	{
		GUI.Box(new Rect (Screen.width/2,20,80,20)," "+ TimeRecord);
		
	}

Is it possible to make the TimeRecord float display change colour over time? E.g If the timer goes to five minutes we change it to orange and if it goes to 10 minutes make it red?

I suspect it might be something like

if (TimeRecord > 300.0F)
{
colour.TimeRecord = orange
}

or something like that.

Thanks in advance!

var fontDefaultColor : Color ; //set these three colors in inspector
var fiveMinColor : Color ;
var tenMinColor : Color ;
 
private var useColor : Color ;
private var minutes : int = 0 ;
 
function Update(){
   Timer();
}
 
function Timer(){
   minutes = Time.time/60 ;
      if(minutes >= 5 && minutes < 10)
         useColor = fiveMinColor ;
      else if(minutes >= 10)
         useColor = tenMinColor ;
      else
         useColor = fontDefaultColor ;
}
 
function OnGUI(){
   GUI.contentColor = useColor ;
 
   GUI.Box(Rect(5,5,100,100),"Time : " + minutes.ToString());
}

That should get you started in the right direction.

…Crap, I just noticed you’re using C#… →

using UnityEngine;
using System.Collections;
public class WhateverScriptName : MonoBehaviour {
 
   public Color fontDefaultColor;
   public Color fiveMinColor;
   public Color tenMinColor;
 
   private Color useColor;
   private int minutes;
 
   void Update(){
      minutes = Mathf.FloorToInt(Time.time/60);
 
      if(minutes >= 5 && minutes < 10)
         useColor = fiveMinColor;
      else if(minutes >= 10)
         useColor = tenMinColor;
      else
         useColor = fontDefaultColor;
   }
 
   void OnGUI(){
      GUI.contentColor = useColor;
    
      GUI.Box( new Rect(5,5,100,100),"Time : " + minutes.ToString());
   }
}