Make Loading Animated Screen - Unity 5.1

2

I'm having trouble making a Loading Screen for my game, the game is a bit big so it takes a while to load, even more for being a mobile game. At the moment I'm trying to do this:

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 for the game to start, it appears the loading screen but does not execute the animation, it gets totally stuck until the game starts. I do not know what else to do. Help me please!

    
asked by anonymous 16.06.2015 / 19:20

1 answer

3

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

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

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

Just note that the scene loading must be above the scene to be loaded. Ex

loading level1 loading level2

You can also use

LoadLevelAsync

    
16.06.2015 / 19:33