Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: wallabie on March 23, 2014, 06:23:09 AM

Title: Dynamically Add/remove textures to spritesheet at runtime on Mobile.
Post by: wallabie on March 23, 2014, 06:23:09 AM
Is there a way to do this in a performant way on Mobile with NGUI?
Title: Re: Dynamically Add/remove textures to spritesheet at runtime on Mobile.
Post by: ArenMook 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.
Title: Re: Dynamically Add/remove textures to spritesheet at runtime on Mobile.
Post by: wallabie 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? 
Title: Re: Dynamically Add/remove textures to spritesheet at runtime on Mobile.
Post by: ArenMook on March 26, 2014, 03:14:30 AM
Just use a UITexture for each.
Title: Re: Dynamically Add/remove textures to spritesheet at runtime on Mobile.
Post by: wallabie 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 ?
Title: Re: Dynamically Add/remove textures to spritesheet at runtime on Mobile.
Post by: ArenMook 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.
Title: Re: Dynamically Add/remove textures to spritesheet at runtime on Mobile.
Post by: wallabie 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.
Title: Re: Dynamically Add/remove textures to spritesheet at runtime on Mobile.
Post by: ArenMook 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.
Title: Re: Dynamically Add/remove textures to spritesheet at runtime on Mobile.
Post by: wallabie 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. 

Title: Re: Dynamically Add/remove textures to spritesheet at runtime on Mobile.
Post by: ArenMook 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.
Title: Re: Dynamically Add/remove textures to spritesheet at runtime on Mobile.
Post by: wallabie 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.