Make Animated Screen Loading - Unity 5.1

Asked

Viewed 786 times

2

I’m having problems to make a Loading Screen for my game, the game is a little big so it takes some time to load, even more because it is a mobile game. At the moment I’m trying to do so:

public bool loading = false;
public Texture loadingTexture;
public float size = 70.0;
private float rotAngle = 0.0;
public float rotSpeed = 300.0;

void Update () {
    if(loading){
        rotAngle += rotSpeed * Time.deltaTime;
    }   
}

void OnGUI() {

    if(loading){

        Vector2 pivot = new Vector2(Screen.width/2, Screen.height/2);
        GUIUtility.RotateAroundPivot(rotAngle%360,pivot);

        GUI.DrawTexture(new Rect ((Screen.width - size)/2 , (Screen.height - size)/2, size, size), loadingTexture); 

    }
}
//Código onde carrega a Scene

public void StartGame()
{
  Application.LoadLevel("Game");
  GameObject.find("Loading").GetComponent<LoadingScreen>().loading = true;
}

But every time I ask the game to start, it appears the loading screen but does not execute the animation, it is totally locked until the game starts. I don’t know what else to do. Help me, please!

1 answer

3


Create an "Scene" only for the loading screen that is not too heavy (otherwise you have to make a loading for the XD loading)

Create an object and place this script inside the update function in the "loading" section"

if(Application.GetStreamProgressForLevel("nomedolevel") ==1){
        Application.LoadLevel("nomedolevel");
    }

Please note that Scene loading must be above Scene to be loaded. Ex

loading level1 loading Level2

You can also use

Loadlevelasync

Browser other questions tagged

You are not signed in. Login or sign up in order to post.