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?