- Home /
Question by
NoirKurosuKai · Jul 29, 2016 at 12:28 PM ·
fontcolor changetimer countdowntimer-script
Changing font color in timer script (js)
Hello guys, I really need help with my timer code... i dunno the problem there are no errors, i changed the color in the inspector and still nothing appears inside the GUI box. Posting the code whole really helps alot guys thnks!!
script (js):
var fontDefaultColor : Color ; //set these three colors in inspector
var TwentySecColor : Color ;
var timer : float = 10.0;
var addTime : float = 10.0;
var f : Font;
var guiShow : boolean = false;
var fontSize: int= 40;
public var guiSkin : GUISkin;
var useColor : Color ;
function Update()
{
timer -= Time.deltaTime;
if(timer <= 0)
{
Application.LoadLevel("Seraph game");
}
else if(timer >= 20 && timer < 25)
useColor = TwentySecColor ;
else
useColor = fontDefaultColor ;
}
function OnGUI()
{
GUI.contentColor = useColor ;
GUI.skin.box.fontSize=20;
GUI.skin.box.wordWrap=true;
GUI.skin = guiSkin;
GUI.skin.font = f;
/////GUI.Box(new Rect(10, 10, 100, 40), "00: " + timer.ToString("0"));
var scalex: float = Screen.width / 1280.0f;
var scaley: float = Screen.height / 720.0f;
GUI.matrix = Matrix4x4.TRS(new Vector3(0, 0, 0), Quaternion.identity, new Vector3(scalex, scaley, 1));
GUI.Box(new Rect(10, 10, 110, 65), "Time left: " + timer.ToString("f2"));
if(guiShow == true)
{
GUI.Box(Rect(120, 10, 45,35), "+" + addTime.ToString("0"));
showGUI();
}
}
function showGUI()
{
yield WaitForSeconds(2);
guiShow = false;
}
Comment