I’m working on a countdown timer with textures. I’ve looked at some of the other questions, but still can’t find the a solution on what i’m trying to do. Right now, Here is my current code:
var num0 : Texture;
var num1 : Texture;
var num2 : Texture;
var num3 : Texture;
var num4 : Texture;
var num5 : Texture;
var num6 : Texture;
var num7 : Texture;
var num8 : Texture;
var num9 : Texture;
public var timeNum : int[];
timeNum = [time2, time];
private var countdown : boolean;
private var currentNumber : Texture;
private var currentNumber2 : Texture;
private var time : int;
private var time2 : int;
private var newNumber = [currentNumber2, currentNumber];
function Start() {
countdown = true;
Countdown();
}
function Countdown () {
if (countdown) {
while (true) {
time -= 1;
yield WaitForSeconds(1);
if(time == 9){
currentNumber = num9;
}
if(time == 8){
currentNumber = num8;
}
if(time == 7){
currentNumber = num7;
}
if(time == 6){
currentNumber = num6;
}
if(time == 5){
currentNumber = num5;
}
if(time == 4){
currentNumber = num4;
}
if(time == 3){
currentNumber = num3;
}
if(time == 2){
currentNumber = num2;
}
if(time == 1){
currentNumber = num1;
}
if(time == 0){
currentNumber = num0;
}
if(time2 == 9){
currentNumber2 = num9;
}
if(time2 == 8){
currentNumber2 = num8;
}
if(time2 == 7){
currentNumber2 = num7;
}
if(time2 == 6){
currentNumber2 = num6;
}
if(time2 == 5){
currentNumber2 = num5;
}
if(time2 == 4){
currentNumber2 = num4;
}
if(time2 == 3){
currentNumber2 = num3;
}
if(time2 == 2){
currentNumber2 = num2;
}
if(time2 == 1){
currentNumber2 = num1;
}
if(time2 == 0){
currentNumber2 = num0;
}
if(time == -1){
if(time2 >= 1){
time2 -=1;
time = 9;
currentNumber = num9;
}
if(time2 <= 0){
countdown = false;
}
}
}
}
}
function OnGUI () {
if(countdown){
GUI.Box ( Rect (15, 325, 400, 200),currentNumber2);
GUI.Box ( Rect (30, 325, 400, 200),currentNumber);
}
}
What I want to do is make it so that I can set the time in the inspector which then will assign the correct number texture based on the number entered. Then in the GUI.Box will countdown showing the number texture.
Right now there are no errors, but, when it runs it only displays the number 1. and nothing else…
Any help available?