I want to display a debug message when the progress bar is loaded fully and I have a button "refresh", when I click this it should reload the progress bar. Here is the code I have tried:
var energyBar : GUIStyle ;
var bgImage : Texture2D; // background image that is 256 x 32
var fgImage : Texture2D; // foreground image that is 256 x 32
static var playerEnergy = 1.0; // a float between 0.0 and 1.0
function Start() {
}
function Update() {
playerEnergy=Time.time *0.02;
if(playerEnergy<=0)
{
Debug.Log("stopped working");
}
}
function OnGUI () {
// Create one Group to contain both images , the first two numbers define the on screen placement
GUI.BeginGroup (Rect (10,10,256,32));
// Draw the background image
GUI.Box (Rect (0,0,256,32), bgImage, energyBar);
// Create a second Group which will be clipped
// We want to clip the image and not scale it, which is why we need the second Group
GUI.BeginGroup (Rect (0,0,playerEnergy * 256, 32));
// Draw the foreground image
GUI.Box (Rect (0,0,256,32), fgImage, energyBar);
if(GUI.Button(new Rect(100,200,60,30),"Refresh"))
{
// code to Restart the progress bar
}
// End both Groups
GUI.EndGroup ();
GUI.EndGroup ();
}
From the above code I am able to display the progress bar, but the problem is that the "refresh" button is not getting displayed and I need help in reloading the progress bar when refresh button is clicked. I also need to print the debug message when the progress bar is fully loaded, but here the debug message is getting displayed when the progress bar starts loading. Can anybody please help me out.
Here I have attached the texture also
No comments:
Post a Comment