3

Is there any build-in way to download and cache anything other than asset bundles. I'd be using asset bundles for my layout, but I don't want to rebuild my entire bundle for the sake of editing 1 texture.

My approach is currently an json which contains the following:

  • Path to the asset bundle containing the layout
  • Paths to the json containing all data about the asset (numbers, text, image paths)

There would be a fair amount of asset bundles, each containing roughly 30-40 images.

I'm using WWW.LoadFromCacheOrDownload to cache my asset bundles, but it doesn't work with textures.

WWWCached data can only be accessed using the assetBundle property!
UnityEngine.WWW:get_texture()

Would there be a build-in way to cache it, or would I have to write the system myself?

Thomas
  • 649
  • 9
  • 17
  • why don't you create the asset bundles? – Roberto Apr 16 '14 at 21:15
  • Each asset bundle would contain about 30 to 40 images, and we'd be having around 20 asset bundles, might be more than 1 app that uses them too. We're not really eager to update every asset bundle that uses that 1 image, instead of just uploading a new version of that single image. – Thomas Apr 17 '14 at 07:47
  • why don't you create 1 asset bundle with the one image? – Roberto Apr 18 '14 at 06:44
  • That would mean extra steps, and it probably won't be our developers that will be updating that, it's highly likely that it's even someone who hasn't even heard from Unity. Also when Unity changes it's version, the asset bundles might become incompatible with the app. – Thomas Apr 18 '14 at 07:15
  • Also, if let's say 20 out of the 40 images would need to be updated, we would need to rebuild 20 asset bundles instead of just uploading 20 images. – Thomas Apr 18 '14 at 07:16
  • In my app, my approach is I separate related textures into different bundles. Download and save into different directory. For reading textures from bundles: i. Create material, then I attach my texture onto it with custom texture settings, ii. Create a prefab attached with Mesh Renderer and apply the material into it. iii. When I want to load the asset, I instantiate the prefab (gameObject) from the bundle and read the texture out from it. Unity suggested that we should write a tool to auto generate those AssetsBundles that we need, especially when your application scale going large. – felixwcf Jun 03 '15 at 07:56
  • I just tried WWW.LoadFromCacheOrDownload to cache images but as you mentioned this works only foe asset bundles and not for any file (like images). So the solution is to make own caching system. It is not too hard to do. I am using Application.persistentDataPath to store downloaded images. – kolodi Dec 10 '16 at 11:26
  • 1
    Yes, I ended up building my own system to handle everything download related. – Thomas Dec 14 '16 at 16:25

0 Answers0