Problem with WWW and webplayer
Asked Answered
H

1

0

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<idCar.Length){ string url = "http://www.mediterrando.net/pauroleague/unity/webplayer/demo/viewscud/"+idCar*+".htm";* _//string url = "http://localhost/pauroleague/unity/webplayer/demo/viewscud/"+idCar*+".htm";*_ _*Debug.Log (url);*_ _*//WWW www = new WWW (url);*_ _*WWW www =WWWLoader.Load(url);*_ _while(!www.isDone) Debug.Log ("Loading "+idCar*+":"+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*=new Car(team);

*_ _*```*_ _cars*.getCar().name=(team.TeamName);*_ _*i++;*_ _*}*_ _*circuit = new Circuit("11");*_ _*}*_ _*
*_ _*```*_ _*

but WWW won't download resources (standalone works)

*_
_*

projects is at

*_
_*

PROJECT

*_
_*

any help would be appreciated*_ _*bye

*_
Hegarty answered 3/7 at 8:50 Comment(1)

It's not c++ it's C#

Berny
H
0

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<limit)StartCoroutine("www.somecontent/"+count+".txt"); }

Hegarty answered 3/10, 2011 at 10:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.