Estou tendo problemas para fazer uma Loading Screen pro meu game, o game está um pouco grande então demora um certo tempo para carregar, ainda mais por ser um game mobile. No momento estou tentando fazer assim:
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;
}
Porém toda vez que peço pro jogo iniciar, ele aparece a tela de loading mas não executa a animação, ele fica totalmente travado até o jogo iniciar. Não sei mais o que fazer. Me ajudem, por favor!