Author Topic: Creating Atlas and Sprites at Runtime [after 3.0]  (Read 3924 times)

tylocook

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Creating Atlas and Sprites at Runtime [after 3.0]
« on: January 31, 2014, 08:26:30 PM »
I was looking at this post that discussed the ability to create an Atlas out of an array of Texture2D objects at runtime.

However, I found out that many of the techniques used in pulling it off have been deprecated from UIAtlas to the point where I am wondering if the ability to make an Atlas at runtime was essentially made unsupported.

Can anyone clarify if this is the case?

Thank you.

Edit: I just read about the existence of UITexture, but I am trying to leverage the single-draw call nature that a UIAtlas provides. I will have thousands of small textures that I am downloading at runtime and packing into a texture using Texture2D.PackTextures().

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Creating Atlas and Sprites at Runtime [after 3.0]
« Reply #1 on: February 01, 2014, 12:57:18 PM »
Texture2D.PackTextures gives you one texture, and returns the list of rectangles in the same order that you fed in the textures.

You can still use UITexture to draw them. Just set the UV rect on each to be what you need it to be. Use the big texture.

UITextures using the same material will end up in the same draw call. No need to make an atlas.

tylocook

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Creating Atlas and Sprites at Runtime [after 3.0]
« Reply #2 on: February 03, 2014, 09:36:23 PM »
Thanks, this worked great once I figured out how to do it. :D