Hello Guest

Author Topic: Texture Packer Support  (Read 8500 times)

cikpis

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 5
    • View Profile
Texture Packer Support
« on: August 13, 2012, 11:24:24 am »
Hello,

I just purchased 2d ToolKit, it's a great tools but I would like to know if is possible to import atlases created using the famous tool "Texture Packer", and if not, if you are planning to add this feature in future.

More questions.

1) Is possible to use "auto alias" or similar feature, to avoid to insert in the atlas texture two identical sprite and save memory?

2) How can I switch HD and SD atlases at runtime?

Thanks in advance.
« Last Edit: August 13, 2012, 11:31:26 am by cikpis »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Texture Packer Support
« Reply #1 on: August 13, 2012, 01:19:04 pm »
Hi cikpis,

There isn't any immediate plans to add import for TexturePacker atlases. That doesn't mean you can't use them though - you can use this runtime sprite collections code to generate sprite collections at runtime, you just need to read the plist / xml data from texturepacker and feed it in here.

1. If you insert the same texture twice into the sprite collection, it won't occupy any additional memory. Matching subimages aren't possible yet due to the overhead in Unity's texture system, it uses a lot of memory already, and this would just increase the footprint.

2. You have to do this manually for now, or with qualitysettings. The main focus of 2D Toolkit 1.80 is having a seamless solution to this, but this is very tricky to get just right because of how Unity works.

cikpis

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Texture Packer Support
« Reply #2 on: August 14, 2012, 09:12:30 am »
Hi unikron!

Sorry for my English, is very bad  :P

However thanks a lot for your answer, but I did not understand how to change the atlas at runtime. How it works?

Unfortunately for you I have another question.

How can I detected a touch( iOS Platform ) in sprite?

Thanks in advance!
« Last Edit: August 14, 2012, 09:14:43 am by cikpis »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Texture Packer Support
« Reply #3 on: August 14, 2012, 06:27:08 pm »
Depends what you want to do with the touch. If you want to detect touch like a button, check out the tk2dButton class. That does just that. Otherwise, you can set up a collider on a sprite and detect it by using a raycast like in the tk2dButton class.

cikpis

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Texture Packer Support
« Reply #4 on: August 16, 2012, 10:29:46 am »
Perfect, Thanks! 

However I did not understand how to change the atlas at runtime. What is the script??

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Texture Packer Support
« Reply #5 on: August 16, 2012, 06:26:17 pm »
You can change atlas by using this function:
http://unikronsoftware.com/2dtoolkit/doc/html/classtk2d_base_sprite.html#a164de5d5a9e9e1058532409faf5deea7

You will need a ref to the sprite collection data object, and the new sprite id to switch to.

cikpis

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Texture Packer Support
« Reply #6 on: August 18, 2012, 01:16:55 pm »
Thanks a lot!

When do you release a new version with auto switch iPhone to iPad?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Texture Packer Support
« Reply #7 on: August 18, 2012, 06:40:34 pm »
The release will be split into two parts. The first will be on-demand loading of sprite collections and the second will be with the auto-switch feature. I can't promise any time-frames except when its ready...

cikpis

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Texture Packer Support
« Reply #8 on: August 18, 2012, 07:19:32 pm »
Thanks for your time!