Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by ZenithCode · Dec 17, 2012 at 03:41 PM · assetbundlewwwcacheprogress-bar

Progress when using WWW.LoadFromCacheOrDownload

I just switched from using new WWW()to WWW.LoadFromCacheOrDownload and it works fine. However the progress value always remains zero.

 void OnClick()
 {
     StartCoroutine(DownloadAndCache(sceneName));
     while (_cachedAssetBundle.progress < 1)
     {
         Debug.Log(string.Format("Progress - {0}%. from {1}", _cachedAssetBundle.progress * 100, _cachedAssetBundle.url));
     }
 }
  
  private IEnumerator DownloadAndCache(string sceneName)
 {
     WWW cachedAssetBundle = WWW.LoadFromCacheOrDownload(sceneName, 1);
     yield return _cachedAssetBundle;
 }

Similar post:

http://forum.unity3d.com/threads/138798-LoadFromCacheOrDownload-progess-bar

Has anyone else encountered this problem? (Not yet tested on Unity 4) Any solutions?

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sanylop · Apr 26, 2013 at 09:47 AM 0
Share

What is the solution?

avatar image ZenithCode · Apr 28, 2013 at 03:51 PM 1
Share

I've edited the question because I still don't have the solution.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by straris2 · Sep 26, 2013 at 08:43 PM

I have putted the progress in the Update function and works for me:

 var scene: String;
 var path: String;
 var download: WWW;    
 
 function Start () {
     
          download = WWW.LoadFromCacheOrDownload (path, 5);
         yield download;
         
         // Handle error
         if (download.error != null)
         {
             Debug.LogError(download.error);
             return;
         }
         
             var bundle = download.assetBundle;           
     }
 function Update () {    
 Debug.Log("Downloading"+download.progress);    
 }
 }
  
Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image vikram Jadhav · Dec 23, 2013 at 07:43 AM 0
Share

Your download.progress is going to be either 0 or 1. So the problem that ZenithCode's mentioned still remains unsolved.

avatar image straris2 · Dec 23, 2013 at 09:05 AM 0
Share

Actually the download.progress gets values from 0 to 1 the tricky part is to be able to listen to that change. As mentioned, the above code worked for me and i used it in a working loading bar. You can find the result here. (the loading bar is a cube that spins and fills in slowly) http://hellenicshoppingcenters.gr/index.php?lang=el

avatar image vikram Jadhav · Dec 31, 2013 at 03:49 AM 1
Share

Yeah, it did work for me, but I had to use wwwObject.isDone ins$$anonymous$$d of yield returning the wwwObject. e.g. following code did give the progress from 0 to 1.

     wwwData = WWW.LoadFromCacheOrDownload( abData.m_strUrl, abData.m_iBundleVersion );
             
     while( !wwwData.isDone )
     {
         m_fDownLoadProgress = wwwData.progress;
         yield return null;
     }
avatar image
0

Answer by morettyCat · Mar 21, 2019 at 11:24 PM

I think the problem is that your are using a while inside a void. It will not wait until IEnumerator finish... You need tu put your while inside IEnumerator before your yield!

I Know maybe it's too late, but maybe for future problems!

 private IEnumerator DownloadAndCache(string sceneName){
 
      WWW cachedAssetBundle =WWW.LoadFromCacheOrDownload(sceneName, 1);
     
      while (_cachedAssetBundle.progress < 1){
           Debug.Log(string.Format("Progress - {0}%. from {1}",_cachedAssetBundle.progress * 100, _cachedAssetBundle.url));
      }
 
      yield return _cachedAssetBundle;
 }


Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

14 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Clean Cache on Mobile 0 Answers

how to delete specific files from cache? 3 Answers

How to determine validity of cached asset bundle 1 Answer

LoadFromCacheOrDownload is sensibly slower than WWW, why? 1 Answer

Issues with WWW.LoadFromCacheOrDownload 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges