var progressbarempty : Texture2D;
var progressbarfull : Texture2D;
var progress : float = 0;
function OnGUI()
{
GUI.DrawTexture(Rect(Screen.width*(0.3/6.55),Screen.height*(0.8/6.55),Screen.width*(0.4/6.55),Screen.height*(1.8/6.55)), progressbarempty);
GUI.DrawTexture(Rect(Screen.width*(0.46/6.55),Screen.height*(2.52/6.55),Screen.width*(0.06/6.5 5),Screen.height*(1.23/6.55)* -Mathf.Clamp01(progress)), progressbarfull);
}
function Update()
{
progress += 0.5 ;
}
Here my progress bar should increases depend on score. when my player answer a correct question he will get 10 marks.for every correct answer he will get 10 marks.when marks of the player increases my progress bar should also increases.
i want to increase the progress bar depend on the correct marks player get.
if he get 10 marks it should increase 0.03 in progress bar.
if he gets 30 marks it should increase 0.09 in progress bar.
like wise i want to increase the progress bar.how to make in this coding.
you can use multiple textures for each progress, according to your score counter
so just populate your progress bar as lets say %0, %25, %50 ,%75,%100, means you have 5 textures
next thing is to use simple if else statements to display them
like
var progressbarempty : Texture2D;
var progressbar1 : Texture2D;
var progressbar2 : Texture2D;
var progressbar3 : Texture2D;
var progressbarfull : Texture2D;
function OnGUI()
{
if(yourcountervariable = 0)
GUI.DrawTexture(Rect(Screen.width*(0.3/6.55),Screen.height*(0.8/6.55),Screen.width* (0.4/6.55),Screen.height*(1.8/6.55)), progressbarempty);
else if(yourcountervariable = 1)
GUI.DrawTexture(Rect(Screen.width*(0.3/6.55),Screen.height*(0.8/6.55),Screen.width* (0.4/6.55),Screen.height*(1.8/6.55)), progressbar1);
else if(yourcountervariable = 2)
GUI.DrawTexture(Rect(Screen.width*(0.3/6.55),Screen.height*(0.8/6.55),Screen.width* (0.4/6.55),Screen.height*(1.8/6.55)), progressbar2);
else if(yourcountervariable = 3)
GUI.DrawTexture(Rect(Screen.width*(0.3/6.55),Screen.height*(0.8/6.55),Screen.width* (0.4/6.55),Screen.height*(1.8/6.55)), progressbar3);
else if(yourcountervariable = 4)
GUI.DrawTexture(Rect(Screen.width*(0.3/6.55),Screen.height*(0.8/6.55),Screen.width* (0.4/6.55),Screen.height*(1.8/6.55)), progressbarfull);
code above is not totally accurate for your project, you need to define and receive yourcountervariable from the mark counter of your player.
hope this helps.