Hello Guest

Author Topic: Download Platform AssetBundle  (Read 4167 times)

TMK

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 16
    • View Profile
    • Dragonhead Games
Download Platform AssetBundle
« on: September 15, 2013, 01:15:08 pm »
Hi,

I'm making a game with 1x, 2x and 4x art, but to avoid the game's download size being unnecessary big for devices that doesn't support 4x, I'm planning to make 4x as an optional AssetBundle download.

How would you recommend doing this? I'm wondering how to switch between e.g. the 2x and newly downloaded 4x AssetBundles on all active sprites in the scene at runtime, keeping their original sizes and positions, like how SpriteCollection's Platform system does.

I have a multi platform SpriteCollection called ScMain, I made an AssetBundle out of "ScMain@4x Data\ScMain@4x.prefab". In the game at startup tk2dSystem.CurrentPlatform is set to 2x, I start the game, download the 4x AssetBundle, then set tk2dSystem.CurrentPlatform = "4x", but not sure how to make it switch the sprites in the scene to the new sprite collection. I've tried to re-load the scene after doing that with "Application.LoadLevel" as well so that 2D Toolkit possibly would re-create the scene with 4x versions, but they stay at 2x.

Thanks!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Download Platform AssetBundle
« Reply #1 on: September 15, 2013, 10:10:19 pm »
Not particularly straightforward - you need to hook it up into the part of tk2dSpriteCollectionData.inst - you will need to modify that so it patches it based on your asset bundle if required. There should be another similar part with fonts, but thats more or less it. To make this work whilst blocking should be straightforward, making this run asynchronously is a bit more complicated.

TMK

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 16
    • View Profile
    • Dragonhead Games
Re: Download Platform AssetBundle
« Reply #2 on: September 16, 2013, 05:39:23 am »
Thanks for the tip! I'll try it out to see how it works out. I also might just tell the user to re-start the game after downloading all the AssetBundles, and then force quit it, so that it will be ready upon the next launch and then load them in like normal.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Download Platform AssetBundle
« Reply #3 on: September 16, 2013, 09:57:30 am »
That'll certainly make things a whole lot easier. You'll still need to patch it in at exactly the same point, but it should be straightforward if you don't have to deal with asynchronous stuff.