- Home /
In Unity 4.1 www.isDone doesn't seem to work in Android. Any suggestion?
Hi everyone !!! I'm trying to make a load class for the StramingAssets and I wrote this stuff:
protected void Awake() {
// let's add the / if not defined in the additional path if it is defined.
if (additionalPath != null && additionalPath.Length != 0) {
if (additionalPath[0] != '\\' && additionalPath[0] != '/') {
additionalPath = "/" + additionalPath;
}
if (additionalPath[additionalPath.Length - 1] != '\\' && additionalPath[additionalPath.Length - 1] != '/') {
additionalPath += "/";
}
}
// get the path to the Streaming Assets folder based on the used platform.
resourcePath = System.IO.Path.Combine(Application.streamingAssetsPath + additionalPath, resourceFilename + "." + resourceFileExtension);
// load the resource file.
if (resourcePath.Contains("://")) {
StartCoroutine(LoadCoroutine(resourcePath, www => { ProcessLoadedResource(www); }));
}
else {
// load with System IO classes
}
}
private IEnumerator LoadCoroutine(string path, Action<WWW> complete) {
WWW www = new WWW(path);
// load the XML and grab contents.
while (!www.isDone) {
yield return www;
}
complete(www);
}
private void ProcessLoadedResource(WWW www){
ManageWwwLoadingResult(www);
// clean up WWW.
www.Dispose();
www = null;
}
Windows an Mac OS X works well because I use another method to load the resources without touching the WWW class.
iOS works with both iPad and iPhone.
Android is not going to work. It seems (seeing the logs in Eclipse), that the while(!isDone) is not working because the call for the use of the loaded resources came before the call to the ProcessLoadedResource(WWW) function. I want to add that the call for the resource is performed by another component in the Start() function.
I really don't know what to do to fix this problem.
Any idea?
Thanks :-)
Your answer
Follow this Question
Related Questions
I can't figure out how to use www to copy a file / very confused about porting to android... 0 Answers
Problem using StreamingAssets on Android build 0 Answers
Streaming Assets android 0 Answers
how do you correctly copy a jpg file from streaming assets folder using www? 1 Answer
How to read xml file on Android using www and StreamingAssets? 2 Answers