the bar is not filling up and also one number is displayed in textblock and level loads…
code:
#pragma strict
var levelname:String;
var loadingscreen:GameObject;
var emptybar:GameObject;
var bar:GameObject;
var percentage:GameObject;
var oldscreen:GameObject;
private var loadprogress:int=0;
function Start () {
loadingscreen.active=false;
emptybar.active=false;
bar.active=false;
percentage.active=false;
}
function Update () {
if(Input.GetKey(KeyCode.Space))
press();
if(Input.touchCount > 0)
{
var touch: Touch = Input.touches[0];
if(touch.phase == TouchPhase.Began && guiTexture.HitTest(touch.position)){
press();
}
}
}
function press()
{
this.guiTexture.pixelInset.width=-8;
this.guiTexture.pixelInset.height=-8;
yield WaitForSeconds(.2);
this.guiTexture.pixelInset.width=0;
this.guiTexture.pixelInset.height=0;
yield StartCoroutine("load");
}
function load()
{
oldscreen.active=false;
loadingscreen.active=true;
emptybar.active=true;
bar.active=true;
percentage.active=true;
var async:AsyncOperation=Application.LoadLevelAsync("level 1");
while(async.progress<=1)
{
Debug.Log(async.progress*100);
loadprogress=async.progress*10;
bar.transform.localScale=Vector3((loadprogress/3),bar.transform.localScale.y,bar.transform.localScale.z);
percentage.guiText.text="Loading "+loadprogress+" %";
yield null;
}
}`enter code here`