Hello,
I am new with programming and making scripts (I am still trying to understand them)
So this is the case, I found some scripts on the web and tried to merge them together for my needs. In this case i wanted to make a loadingscreen.
*Problem : Something is calling it multiple times and because of that it looks like it’s shuffling a deck of cards. And after the 5 second restSeconds it doesn’t want to disable the GUI.
This is the script i am using.
private var startTime;
private var restSeconds : int;
private var roundedRestSeconds : int;
var countDownSeconds : int;
static var LoadingScreenOn = true;
//Texture
var Picture_1 : Texture2D;
var Picture_2 : Texture2D;
var Picture_3 : Texture2D;
var Picture_4 : Texture2D;
var Picture_5 : Texture2D;
function Start ()
{
//Called in when entering another scene.
startTime = Time.time;
var guiTime = Time.time - startTime;
restSeconds = countDownSeconds - (guiTime);
//As soon the timer hit 5, the LoadingScreen-GUI will be disabled.
if (restSeconds == 5) {
Loading_Screen.LoadingScreenOn = false;
guiTexture.enabled = false;
}
}
//required to let the randomize succeed.
function Update ()
{
if (Loading_Screen.LoadingScreenOn == true)
{
RandomPic();
guiTexture.enabled = true;
}
}
//randomize a picture to be displayed
function RandomPic()
{
var randPic = Random.Range(0, 5);
var chosenPicture = randPic;
switch (chosenPicture)
{
case 0:
guiTexture.texture = Picture_1;
break;
case 1:
guiTexture.texture = Picture_2;
break;
case 2:
guiTexture.texture = Picture_3;
break;
case 3:
guiTexture.texture = Picture_4;
break;
case 4:
guiTexture.texture = Picture_5;
break;
}
}
I have no idea why it is behaving like this. I hope you guys can help me out.
-Hexer