Hello Guest

Author Topic: Creating SpriteFromTexture Dynamically  (Read 4104 times)

Sam K

  • Newbie
  • *
  • Posts: 3
    • View Profile
Creating SpriteFromTexture Dynamically
« on: August 18, 2014, 08:22:08 am »
hi,  I want to create and load images dynamically . Im fetching my data from AssetBundle.
Whats the proper way of creating SpriteFromTexture dynamically ( 1- Create Gameobject and AddComopnents, 2- Prefabs, 3-Some builitin tk2d way 4 or any other ). and how to load images into it dynamically.
Im using this with NGUI and it works fine.. But my requirement is to use Tk2d.. so how to address this issue ??

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Creating SpriteFromTexture Dynamically
« Reply #1 on: August 18, 2014, 08:57:24 am »
Check the runtime sprite collections sample - it shows a few ways of creating sprites at runtime. One option is to load texture packer atlases, another is to simply create one or more sprites from a texture.

Also please don't cross post.

Sam K

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Creating SpriteFromTexture Dynamically
« Reply #2 on: September 26, 2014, 11:30:08 am »
Oh i wanted to ask another question related to this and found out it was me who posted..
when i Create a sprite from texture another GameObject Is created other than the sprite. A tk2dSpireCollectionData script is attached to it.

Now if i want ot create lets say 100 such sriptes 100 other seperate objects will be created(not parented). Is there anyway to not show these objects in the heirarchy or they are not created ??
« Last Edit: September 26, 2014, 11:42:29 am by Sam K »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Creating SpriteFromTexture Dynamically
« Reply #3 on: September 26, 2014, 09:33:46 pm »
Quote
Now if i want ot create lets say 100 such sriptes 100 other seperate objects will be created(not parented). Is there anyway to not show these objects in the heirarchy or they are not created ??

No there isn't, but if you're doing this in code, you can use the reference to the created sprite collection object to create others from the same one. Check the runtime sprite collections sample for more details on that.

Otherwise if you just want to hide them you could patch the code I guess, but it'll be hard to see when things are left behind for any reason...