Quantcast
Channel: Questions in topic: "crash"
Viewing all articles
Browse latest Browse all 2383

Switch Levels with Async and still display progress

$
0
0
I have a serious issue. **Before you read, please note. I am testing this by using a webplayer build interacting with the editor build and running both at the same time because I need to test a lot of networking code built into this thing. If that is the reason, please let me know.** The problem is that if I enable "LoadLevelAsync" at all, it just freezes and makes both the webplayer and the editor unresponsive. I don't know why. I also tried posting the async code outside of an enumerator, and still. Nothing. { public UILabel PercentageLabel; private Utilities utility; private PlayerSettings playerSettings; private AsyncOperation theGame; private bool CountIncremented = false; void Awake() { utility = GameObject.Find("LoadManager").GetComponent(); theGrid = GameObject.Find("CharacterGrid"); gridComponent = theGrid.GetComponent(); // Find Playersettings, set the NameLabelText, load the sprite playerSettings = GameObject.Find("LoadManager").GetComponent(); //StartCoroutine("LoadUpLevel"); } void Update() { PercentageLabel.text = (((int)(theGame.progress * 100f)).ToString() + "%"); if (theGame.isDone && !CountIncremented) { networkView.RPC("IncrementCount", RPCMode.Server); CountIncremented = true; } if (utility.ICanLoadTheLevel) { utility.ICanLoadTheLevel = false; CountIncremented = false; if (theGame.isDone) { theGame.allowSceneActivation = true; } } } void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info) { int asyncprog = 0; if (stream.isWriting) { asyncprog = (int)(theGame.progress * 100f); stream.Serialize(ref Charname); stream.Serialize(ref isServer); //stream.Serialize(ref asyncprog); } else { stream.Serialize(ref asyncprog); //PercentageLabel.text = (asyncprog.ToString() + "%"); } } [RPC] void IncrementCount() { //utility.PlayersFinishedLoading++; //if (utility.PlayersFinishedLoading >= utility.TotalPlayersInGame) //{ // utility.StartTheGame();//RPCs utility.ICanLoadTheLevel = true; //} } IEnumerator LoadUpLevel() { theGame = Application.LoadLevelAsync("MYGAMENAMEHERE"); theGame.allowSceneActivation = false; yield return theGame; } } Should I not be using an enumerator? Is this impossible, and if so, why? I realize async is quite complicated, so thank you for your time.

Viewing all articles
Browse latest Browse all 2383

Trending Articles