Hello,
Ive got a game, each screen is in a separate scene. etc.
I have an issue with my level GUI. Ive got a time bar decreasing in size using a texture. Odd thing is that this script runs before this scene is loaded. Ive also noticed this particular script or correctly put the instantiation of this script doesnt reset like others when leaving and reloading the scene.
The script is below, could anyone tell me why this script is behaving like this? Thank you ![]()
var timeProgress : float;
var pos : Vector2;
var size : Vector2;
var pos2 : Vector2;
var size2 : Vector2;
var pos3 : Vector2;
var size3 : Vector2;
var timeBarEmpty : Texture2D;
var timeBarFull : Texture2D;
var timeBarCover : Texture2D;
var timeIcon : Texture2D;
var speed : float;
var d1 : float;
var barLength : float;
function OnGUI()
{
GUI.depth = d1;
GUI.DrawTexture(Rect(pos.x, pos.y, size.x, size.y), timeBarEmpty);
GUI.depth = d1;
GUI.DrawTexture(Rect(pos.x, pos.y, barLength, size.y), timeBarFull);
GUI.depth = d1;
GUI.DrawTexture(Rect(pos2.x, pos2.y, size2.x, size2.y), timeBarCover);
GUI.depth = d1;
GUI.DrawTexture(Rect(pos3.x, pos3.y, size3.x, size3.y), timeIcon);
}
function Start()
{
ResetGUI();
}
function Update()
{
barLength = size.x * timeProgress;
if(timeProgress > 0)
{
timeProgress = 1-(Time.time * speed);
}
else
{
EndGame();
}
}
function EndGame()
{
yield WaitForSeconds(2);
Camera.main.SendMessage("fadeOut");
yield WaitForSeconds(1.5);
Application.LoadLevel("MainMenu");
}
function ResetGUI()
{
timeProgress = 1;
size.x = 310;
barLength = 310;
}