- Home /
WWW.progress not working on Android | iOS
Hello. I'm having difficulty tracking progress using a WWW class. On mobile platforms WWW.progress value does not change linearly, it is 0 (when loading) or 1 (when the finish).
On PC & MAC all Ok. I mean that the PC value goes smoothly from 0 to 1 (0.1 0.2 0.3 .... 1). But on mobile platforms this is not happening! Is 0 or 1, no 0.2 0.4 etc.. Rigidly 0 or 1. Help! Unity 4.3.0f4 Pro
using UnityEngine;
using System.Collections;
public class ExampleLoadingBundle : MonoBehaviour {
public string url = "http://pancrucian.littleteam.ru/myAssetBundle.unity3d";
public int version = 1; // The version of the AssetBundle
public string assetName = "Object Name";
public tk2dTextMesh textMesh;
public AudioSource ObjInstance;
void Start(){
StartCoroutine(LoadBundle<AudioClip>(url, version,assetName));
}
public IEnumerator LoadBundle<T> (string url, int version, string assetName) where T : Object {
using(WWW download = WWW.LoadFromCacheOrDownload(url, version)){
while(!download.isDone) {
textMesh.text = download.progress.ToString(); // THIS PART NOT WORKING, PROGRESS ALWAYS 0 THEN 1 IF download.isDone
textMesh.Commit();
yield return 0;
}
yield return download;
if (download.error != null) {
textMesh.text = download.error;
download.Dispose();
textMesh.Commit ();
yield break;
}
AssetBundle assetBundle = download.assetBundle;
download.Dispose();
if (assetName == "" || assetName == null)
ObjInstance.clip = (AudioClip)assetBundle.mainAsset;
else
ObjInstance.clip = (AudioClip)assetBundle.Load(assetName, typeof(T));
assetBundle.Unload(false);
}
ObjInstance.Play();
}
}
Typically you see this behaviour when the server is returning bad header information. If it's not returning a content length, Unity has no way of giving you progress, since progress is a percentage of the total content length.
Is the server you're contacting giving back different headers depending on whether you're connecting from a mobile client or not?
checked: on my server content length not returning on mobile devices ;(
i have faced this same issue from last couple of days on web player. can you help me how could i fix my server. pls explain me step by step . Thanks in advance.
Answer by PanCrucian · Dec 12, 2013 at 05:39 PM
Thx this guy http://answers.unity3d.com/users/14179/noaa-julien.html
Typically you see this behaviour when the server is returning bad header information. If it's not returning a content length, Unity has no way of giving you progress, since progress is a percentage of the total content length.
Server code:
$attachment_location = 'files/myAssetBundle.unity3d';
header($_SERVER["SERVER_PROTOCOL"] . " 200 OK");
header("Cache-Control: public");
header("Content-Type: application/zip");
header("Content-Transfer-Encoding: Binary");
header("Content-Length:".filesize($attachment_location));
header("Content-Disposition: attachment; filename=myAssetBundle.unity3d");
readfile($attachment_location);
Die();
And now all working great! ;p
Okay, i have same with www.progress trouble on webplayer build(when strea$$anonymous$$g video in movie texture). Where i must Paste that Server code ? What changes i must to do in that code for .ogv video file ?
have you got solution for problem ?? I am facing this same issue from the last couple of days. Any solution ??
Is there any way to changes the c# script in Unity to read the right header ins$$anonymous$$d of the Server itself?
Can you tell me what is the file type (extention) of asset bundle 'cause i tried using .unity3d to download asset bundle it doesnt work.
Can you tell where to put this code, and what to write for assetbundles
Hello, i have the same problem,have you solved it?
That a PHP code, but it doesn't really matter in which program$$anonymous$$g language it is written. The idea is to transmit the response headers. Learn about HTTP headers