使用WWW.LoadFromCacheOrDownload方法加载文件时,其进度(www.progress)在IOS(iPhone/iPad)上只有0和1两个值,不会(0.1,0.2,0.3……)这样平滑的过渡,但在PC和Android上能正常。
解决方法是:1、按照下面设置好HTTP头,2、将要下载的文件后缀设置好mime类型(application/octet-stream )
参照:http://answers.unity3d.com/questions/594668/wwwprogress-not-working-on-android-ios-1.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();