Trying to pause the countdown in this script.

So I’ve been working with NGUI and because I’m working and familiar with Java, NGUI is written in C#. I’ve created this script to access some of it’s functions for it’s progression bar.

The problem is, I’m trying to pause the cooldown, when the game’s “paused”

I’ve been able to pause just about everything I want except using a boolean switch grabbed from another script “clock”.

Everything I have runs off of a float called “playTime”.

However, I for the life of me, can’t pause this script.

#pragma strict

var coolTimeMax:			float 		= 0.5f;

private var timer:			float       = 0.0f;
private var coolTime:		float 		= 0.0f;
private var silder:			UISlider 	= null;
private var getCowCam:		GameObject;
private var isUseSkill:		boolean 	= false;

private var getClock:			GameObject;									// getting clock and all it's components
private var getPlayTime: 		float 	= 0.0;
var getPlayTimeEnabled: boolean = true;

function Start () 
{
	silder = GetComponent(UISlider);
	StartTimer ();
	getCowCam = GameObject.FindGameObjectWithTag("MainCamera");
	getClock = GameObject.FindGameObjectWithTag("clock");
}

function Update ()
{
	getPlayTime = getClock.GetComponent(clock).playTime;
	getPlayTimeEnabled = getClock.GetComponent(clock).playTimeEnabled;
	
	silder.sliderValue = timer;
	
	if (UICamera.hoveredObject != null && UICamera.hoveredObject.name == ("Progress Bar") && Input.GetMouseButton(0) && !isUseSkill && timer == 1)
	{
		isUseSkill = true;
		getCowCam.GetComponent(InGameGUI).GetToLauncher ();
	}
	if (isUseSkill) 
	{
		StartTimer ();
		isUseSkill = false;
	}
}

function StartTimer ()
{
	var t: float = 0.0f;
		
	while (t < 1)
	{
		t += Time.deltaTime / coolTimeMax;
		timer = Mathf.Lerp (0, 1, t);
		yield;
	}
	
}

The function in question is “StartTimer”. The boolean for detecting pause is “getPlayTimeEnabled”.

Can anyone lend a hand here?

Unity does allow limited interaction between C#, JavaScript, and the other supported scripting languages. Scripts in certain folders are compiled before others, such as the “Standard Assets” and “Plugins” folders. If you put NGUI’s scripts into one of those folders, so that they’re compiled before your scripts, you should be able to call them from JavaScript.

(Personally, I’m a bit surprised that NGUI isn’t set up that way by default.)

For specific instructions and tips, see How to use NGUI with javascript? here on Unity Answers, or Using NGUI with javascript over at the Tasharen forums.