Author Topic: Dynamically Add/remove textures to spritesheet at runtime on Mobile.  (Read 3056 times)

wallabie

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 200
    • View Profile
Is there a way to do this in a performant way on Mobile with NGUI?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dynamically Add/remove textures to spritesheet at runtime on Mobile.
« Reply #1 on: March 24, 2014, 06:36:56 PM »
I wouldn't do it at run-time because PackTextures is a very slow operation. The fastest thing to do is to just have a pre-determined grid that you'd use instead. For example if you have a 1024x1024 texture, and you need 256x256 thumbnails, you can fit 4x4=16 of them in there. You can still draw specific images within the larger texture by setting the UV rect on the UITexture.

wallabie

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 200
    • View Profile
Re: Dynamically Add/remove textures to spritesheet at runtime on Mobile.
« Reply #2 on: March 24, 2014, 08:30:20 PM »
My use case is that i am making an IOS photo gallery with the scrollview component.

The photos are coming from the server, how then to best display these photos within the scrollview? 

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dynamically Add/remove textures to spritesheet at runtime on Mobile.
« Reply #3 on: March 26, 2014, 03:14:30 AM »
Just use a UITexture for each.

wallabie

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 200
    • View Profile
Re: Dynamically Add/remove textures to spritesheet at runtime on Mobile.
« Reply #4 on: March 26, 2014, 04:26:36 AM »
Would this mean that each UITexture is one extra drawcall ?

If I'm using the Infinite Scrollview, then would this mean that only the items that are visible will add to the drawcalls ?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dynamically Add/remove textures to spritesheet at runtime on Mobile.
« Reply #5 on: March 26, 2014, 08:19:52 PM »
Yes, it would mean extra draw calls, but only for ones that are visible, especially in case of the infinite scroll views.

wallabie

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 200
    • View Profile
Re: Dynamically Add/remove textures to spritesheet at runtime on Mobile.
« Reply #6 on: March 29, 2014, 04:02:11 AM »
Great,

Does the infinite scrollview support drag and drop operations as in the normal scrollview.  Reason I am asking is because it doesn't seem to use the grid like the normal scrollview.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dynamically Add/remove textures to spritesheet at runtime on Mobile.
« Reply #7 on: March 29, 2014, 06:23:46 AM »
No, grid and infinite scroll view (which is done through UIWrapContent) are two different things. Both reposition children using different logic.

wallabie

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 200
    • View Profile
Re: Dynamically Add/remove textures to spritesheet at runtime on Mobile.
« Reply #8 on: March 29, 2014, 07:27:17 AM »
Can you also add drag/drop support to the infinite scrollview because the scrollviews should be consistent.  We were asking for a performant scrollview that can support many items, you promised and delivered, but now we have to lose drag/drop.  What we were asking for was an improvement of the Existing Scrollview to be more performant not another kind of scrollview that is lacking in features of the original scrollview.  2DTK is a sprite solution but their GUI scrollview is even more performant than NGUI, which is supposed to be a dedicated GUI system. 


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dynamically Add/remove textures to spritesheet at runtime on Mobile.
« Reply #9 on: March 30, 2014, 07:01:57 AM »
Why would you lose the drag & drop? Drag & drop works by re-parenting a UI item that you're dragging. You can do it with or without a grid. Grid's presence is just used for simple positioning. It's not a mandatory component.

wallabie

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 200
    • View Profile
Re: Dynamically Add/remove textures to spritesheet at runtime on Mobile.
« Reply #10 on: March 30, 2014, 02:24:07 PM »
Cool, so this means that I can use the Grid with the Infinite ScrollList and have Drag/Drop.