- Home /
Question by
xproject2013 · Feb 27, 2014 at 09:02 AM ·
c#freezeloadlevel
Application.LoadLevel freeze at first load
Hi everyone,
in the first scene of my application (for web player) I load data from an xml file. Once the xml file has been loaded I load the first level of my application but at the first time that I use my app in the html page the xml data is loaded but the next level is not loaded .
If I refresh the html page it work properly.
I need that the webplayer load scene properly also the first time is loaded. Does anyone can help me? Here is the code I used:
using UnityEngine;
using System.Collections;
using System.Xml;
public class XmlLoadProducts : MonoBehaviour {
string xml;
XmlDocument xmlDoc;
WWW www;
public UILabel response;
void Start(){
startLoad();
}
void startLoad(){
StartCoroutine( LoadConfig() );
}
IEnumerator LoadConfig() {
Data.isXmlProductsLoaded = false;
www = new WWW(Data.xmlProductsOnline);
yield return www;
//no error occured
if (www.error == null) {
xml = www.data;
Data.xmlProducts = new XmlDocument();
Data.xmlProducts.LoadXml(xml);
response.text = Localization.Localize("LoadComplete");
Data.isXmlProductsLoaded = true;
// error
} else {
Debug.Log("ERROR: " + www.error);
response.text = Localization.Localize("Error") +": "+ www.error;
Data.isXmlProductsLoaded = false;
}
www.Dispose();
www = null;
yield return Data.xmlProducts;
yield return new WaitForSeconds(1);
if (Data.isXmlProductsLoaded){
//Application.ExternalCall("debug", "Load next scene");
Application.LoadLevel("1.StyleSelection");
Debug.Log("products xml loaded");
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Can a script be loaded to a next scene? 3 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Unity freezes on play 2 Answers
Load new scene, controls freeze 0 Answers