- Home /
Problem with WWW and webplayer
hi, I've problems downloading text files (with .htm extension) from url inside webplayer. All works on standalone version I've implemented WWWLoader script:
using System;
using System.Collections;
using UnityEngine;
public class WWWLoader:MonoBehaviour
{
private static WWWLoader s_Instance = null;
public static WWWLoader instance
{
get
{
if (s_Instance == null)
{
GameObject obj = new GameObject("_WWWLoader");
s_Instance = (WWWLoader)obj.AddComponent(typeof(WWWLoader));
}
return s_Instance;
}
}
public IEnumerator WaitForLoad(WWW www)
{
yield return www;
if (www.error != null)
{
Debug.Log("WWWLoader Error - \"" + www.url + "\" : "+ www.error);
} else {
Debug.Log("WWW completed!");
}
}
public static WWW Load(string url)
{
WWW www = new WWW(url);
instance.StartCoroutine(WWWLoader.instance.WaitForLoad(www));
return www;
}
}
i use this class in my script:
private string[] idCar=new string[]{"496","1800","1346"};
... void Import (string raceId) { int i=0; while(i http://www.mediterrando.net/pauroleague/unity/webplayer/demo/viewscud/"+idCar[i]+".htm"; //string url = " http://localhost/pauroleague/unity/webplayer/demo/viewscud/"+idCar[i]+".htm"; Debug.Log (url); //WWW www = new WWW (url); WWW www =WWWLoader.Load(url); while(!www.isDone) Debug.Log ("Loading "+idCar[i]+":"+www.error+":"+www.progress); //yield return www; ImportScuderia importer = new ImportScuderia (www.text); Scuderia team = importer.getTeam (); Debug.Log ("TeamName=" + team.TeamName); Debug.Log ("TeamCar=" + team.TeamCar); //Circuit circuit=new Circuit(); cars[i]=new Car(team);
cars[i].getCar().name=(team.TeamName); i++; } circuit = new Circuit("11");
} </code>
but WWW won't download resources (standalone works)
projects is at
any help would be appreciated bye
Answer by trumanita · Oct 03, 2011 at 10:15 AM
I think I understood the problem: I can't use a while loop to load a sequence of WWW content, instead I have to call my Load method recursively as Coroutine: private int count=0; void Awake(){ //load www string url="www.somecontent/"+count+".txt"; StartCoroutine(Load(url)); } ... IEnumerator Load (string url){ WWW www=new WWW(url); yield return www; count++; if(count
Your answer
Follow this Question
Related Questions
What's the matter downloading with 3G 0 Answers
Why won't the webplayer work after I install it? 3 Answers
www can't download file in webplayer 4 Answers
www.texture different in editor and on webplayer 1 Answer
www.texture memory leak 1 Answer