Problem with Colider/Trigger and OnGUI function

This is related to link text

But somehow I cannot ask another question there.

So here it is. Two scripts are a bit changed.

TimingTriggers.js

enum TriggerType 

{

	start, split1st, split2nd

}



var triggerType : TriggerType;

and TimedItem.js

public var sectionShow : float = 0.0f;
var myTime : float = 0.0f;

private var startCount : boolean = false;
private var section1st : boolean = false; 
private var section2nd : boolean = false;
private var sectionTemp : boolean = false;

private var myLapTime : float = 0.0f;


private var iMinutes : int;
private var iSeconds : int;
private var iTens : int;
private var iHundreths : int;
private var iThousenths : int;
var LapTime : String;
private var OldLapTime_1 : String;
private var OldLapTime_2 : String;
private var OldLapTime_3 : String;
var OldLapTime_temp : String;


function Update () {

	// If new lap is started, reset all, preserve old lap times
	if(startCount)
	{
		sectionTemp = true;

		OldLapTime_3 = OldLapTime_2;
		OldLapTime_2 = OldLapTime_1;
		OldLapTime_1 = LapTime;	
				
		myLapTime = 0.0f;
		startCount = false;
		section1st = false;
		section2nd = false;
	}
	
	// Time calculation
	if(sectionTemp)
	{
		// Time counter
		myLapTime += Time.deltaTime;
		
		iMinutes = (myLapTime/60f);
		iSeconds = (myLapTime%60f);
		iTens = ((myLapTime*10)%10);
		iHundreths = ((myLapTime*100)%10);
		iThousenths = ((myLapTime*1000)%10);
		LapTime = String.Format("{0:00}:{1:00}:{2:0}{3:0}{4:0}",iMinutes,iSeconds,iTens,iHundreths,iThousenths);
	}
}

// This is funciton from your post, but some things are added
function OnTriggerEnter(other : Collider)
{
	var timing = other.GetComponent(TimingTriggers);
	if(timing)
	{
		switch(timing.triggerType)
		{
			
			//Car passed Start Line
			case TriggerType.start:
			Debug.Log("Start");
			startCount = true;
			break;
			
			//Car passed 1st split time Line
			case TriggerType.split1st:
			Debug.Log("1st");
			section1st = true;
			break;
			
			//Car passed 2nd split time Line
			case TriggerType.split2nd:
			Debug.Log("2nd");
			section2nd = true;
			break;

			
		}
	}
}

// This script is showing Lap Times on GUI
function OnGUI()
{
	GUI.Box (new Rect(Screen.width/2-120,5,240,50), "");
	GUI.Label(new Rect(Screen.width/2-110,5,100,20), "" + LapTime);
	if(startCount)	// HERE IS PROBLEM
	{
		GUI.Label(new Rect(Screen.width/2,5,100,20), "" + OldLapTime_1);
		GUI.Label(new Rect(Screen.width/2,20,100,20), "" + OldLapTime_2);
		GUI.Label(new Rect(Screen.width/2,35,100,20), "" + OldLapTime_3);
	}
}

Problem is in last part of OnGUI function, it depends of Trigger, but when triggered it shows nothing on GUI.

Cheers

In your Update function (which runs every frame) you do this:

if(startCount)
{
   sectionTemp = true;

   OldLapTime_3 = OldLapTime_2;
   OldLapTime_2 = OldLapTime_1;
   OldLapTime_1 = LapTime;   

   myLapTime = 0.0f;
   startCount = false;
   section1st = false;
   section2nd = false;
}

Which sets startCount to false immediately if it was true…