Author Topic: update atlas from script  (Read 4023 times)

VamppiV

  • Newbie
  • *
  • Thank You
  • -Given: 5
  • -Receive: 1
  • Posts: 15
    • View Profile
update atlas from script
« on: October 16, 2014, 08:38:09 AM »
I'm looking for the easiest way to update atlas from script. I have UIAtlas and I want put dynamically new photos in. I was trying PackTextures but I wrapped up.

I want to do something easy like this:

public UIAtlas atlas;
Texture2D snap;

void OnClickedAtlasBlaBla(){
atlas.UPDATE(snap);
}

And I'm looking for something like update function. Any ideas?

VamppiV

  • Newbie
  • *
  • Thank You
  • -Given: 5
  • -Receive: 1
  • Posts: 15
    • View Profile
Re: update atlas from script
« Reply #1 on: October 16, 2014, 09:43:14 AM »
I need it for do something like this:

newSprite.SetRect(x,y,texWidth,texHeight);
newSprite.atlas = atlas;
newSprite.spriteName=photoAddress;

And it works, but I don't know how to update (or make) atlas. I found class UIAtlasMaker, but I don't know how to use it.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: update atlas from script
« Reply #2 on: October 17, 2014, 04:49:47 AM »
Don't try to create atlases at run-time. If you need to pack many textures into one (and in most cases you don't need to), then just use a UITexture and specify a UV rect.

VamppiV

  • Newbie
  • *
  • Thank You
  • -Given: 5
  • -Receive: 1
  • Posts: 15
    • View Profile
Re: update atlas from script
« Reply #3 on: October 17, 2014, 09:05:07 AM »
Don't try to create atlases at run-time. If you need to pack many textures into one (and in most cases you don't need to), then just use a UITexture and specify a UV rect.
Hm, okey, I remember. But what can I do if I'm making textures in runtime and I have to show them at one screen? It generetes a lot of drawcalls. UV rect? Any simple tutorial? Because I was trying and I completely didn't understand how does it work

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: update atlas from script
« Reply #4 on: October 18, 2014, 08:31:15 AM »
NGUI batches everything by materials. You can have one large texture with many smaller inside of it. As long as you use the same material by your UITextures, they will all be drawn in the same draw call.