Hello Guest

Author Topic: Runtime Create SpriteCollection and SpriteAnimation.  (Read 3997 times)

DarkMagicCK

  • Newbie
  • *
  • Posts: 4
    • View Profile
Runtime Create SpriteCollection and SpriteAnimation.
« on: December 30, 2012, 04:56:13 pm »
Hello, this is a great question fucking me these days.

Our boss needs game level DLC feature (using Asset Bundle), so I have no choice but to create all sprites at runtime. But then I'm got some prob.
I've worked out how to create SpriteCollection at Runtime, according to this post http://unikronsoftware.com/2dtoolkit/forum/index.php/topic,935.msg4519.html#msg4519.

Note that my Resources or AssetBundle will include the SpriteCollection and SpriteAnimation which have already been done in editor.
I'm not asking how to create collection from png file or how to create animation using SpriteAnimationFrame.
So here are my questions:

  1. Resource.Load() will create an object instance, if I use Resource create the same SpriteCollection many times, will it take many spaces. That means, if my "collection1" has a texture, and I Resource.Load("collection1") for 2 times, will unity load 2 textures into space? Or I should need a hashtable to check if a SpriteCollection is created.

  2. I do not know if I can create SpriteAnimation using Resource.Load() because the SpriteAnimationFrame is based on different SpriteCollection. So if I want to create SpriteAnimation , do I need to Resource.Load() the Collection first? Or it's just impossible?

I really suggest you to add something like tk2dGlobal, which do something like:
Code: [Select]
bool tk2dGlobal.AddSpriteCollection("name in resource folder");
bool tk2dGlobal.AddSpriteAnimation("name in resource folder");//which will automatically add the needed collections
SpriteAnimationClip tk2dGlobal.GetAnimationClipInAnimationLibrary("clip name", "anim lib name");
SpriteCollection tk2dGlobal.GetSpriteCollection("name in resource folder");
GameObject tk2dGlobal.CreateSprite(clip);

So please help me solve this problem.
« Last Edit: December 30, 2012, 06:35:14 pm by DarkMagicCK »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Runtime Create SpriteCollection and SpriteAnimation.
« Reply #1 on: December 30, 2012, 05:39:43 pm »
Please stop using rude language and I'll answer the question.

DarkMagicCK

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Runtime Create SpriteCollection and SpriteAnimation.
« Reply #2 on: December 30, 2012, 06:34:24 pm »
ah sorry, just use the rude words to describe my feelings about question, not to be impolite to you . Please help me to solve this.