x


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

but WWW won't download resources (standalone works)

projects is at

PROJECT

any help would be appreciated bye

more ▼

asked Oct 02 '11 at 06:10 PM

trumanita gravatar image

trumanita
54 12 16 18

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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"); }

more ▼

answered Oct 03 '11 at 10:15 AM

trumanita gravatar image

trumanita
54 12 16 18

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x810
x663
x525
x195

asked: Oct 02 '11 at 06:10 PM

Seen: 575 times

Last Updated: Oct 03 '11 at 10:15 AM