Hello Guest

Author Topic: Saving tk2dSpriteAnimation Prefab  (Read 3969 times)

Rif

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 3
    • View Profile
Saving tk2dSpriteAnimation Prefab
« on: September 11, 2014, 10:51:14 am »
The game I currently has about 100 characters. So importing all the character atlas and animation with the game app wouldn't be a good approach (making the download way too big).

So what should I be doing if I want to including the character animation in separate download process.

Currently I can export the character's tk2dSpriteAnimation as .unity3d file, download them, and change the library of tk2dSpriteAnimator of character animation
Code: [Select]
IEnumerator DownloadPrefab(string url)
{
WWW downloadedFile = new WWW(url);
yield return downloadedFile;

if (downloadedFile.isDone)
{
AssetBundle assetBundle = downloadedFile.assetBundle;

spriteAnimation = assetBundle.Load("BattleAnim-CharacterA", typeof(tk2dSpriteAnimation)) as tk2dSpriteAnimation;
}
else
{
print("downloadedFile is null");
}
}
characterSpriteAnimator.Library = spriteAnimation;

But this way will make the user download a lot of characters every time they want to initiate a battle (The battle consists of 7 characters vs 7 characters, so if every sprite animation library size is 1.5 MB on average, that will be 21MB to download for just 1 battle).

Is there a way to save the tk2dSpriteAnimation I downloaded into prefab in the deployed app, so that I do not need to download the sprite animation everytime the user initiate the battle?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Saving tk2dSpriteAnimation Prefab
« Reply #1 on: September 13, 2014, 12:25:52 pm »
you cant save the prefab, but you'd save the assetbundle. You can then load it using a file:/// uri. Or you could try WWW.LoadFromCacheOrDownload or similar API functions.

Rif

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Saving tk2dSpriteAnimation Prefab
« Reply #2 on: September 15, 2014, 04:20:03 am »
Thanks for the reply.
It seems my question is more of Unity general question rather than a tk2d related.

But is my way of approach correct in this? i.e. Exporting the tk2dSpriteAnimation as a single .unity3d asset bundle ? (With dependency tracking)

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Saving tk2dSpriteAnimation Prefab
« Reply #3 on: September 15, 2014, 11:42:42 am »
That will work, but only if you dont use platform collections. Platform collections rely on Resources.Load which dependency tracking wont track.