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!