Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: amraffay on May 06, 2015, 02:25:37 PM
-
Hi there,
I'm creating an image gallery using ScrollView > Grid > Prefabs of Images just like attached image. I add these prefabs on runtime using NGUI.AddChild and and i load images using two Resources.load
Now im not really happy with this approach as in other technologies list is virtualized and 100 items are just 10 items and simply resetting data (automatically loading/unloading runtime textures)
How can i achieve same thing in NGUI, so my gallery perform betters. It loads textures which user is seeing and unload them to save device memory which are hidden.
This is quite important for not just me but many other out there.
Thanks :)
-
UIWrapContent is your friend.
http://www.tasharen.com/ngui/docs/class_u_i_wrap_content.html
-
I believe this is much complex problem than WrapContent as we have to handle images somehow.
-
Yeah it is. But WrapContent can give you the basis for it, if the content you cycle around is containers for your images, which look into a deeper data layer (that you set up yourself) and update to the relevant image on the OnInitializeItem callback.
-
Ok i looked into UIWrapContent and it looks what i need, few items which are just changing data.
However as i'm pretty new to everything, is there any tutorial/documentation page for UIWrapContent?
Thanks
-
There is an example that comes with NGUI that uses it. Aside from it, all you will want to do is set UIWrapContent.onInitializeItem delegate. It will be called whenever an item is being repositioned, letting you update its data much like I do in the example.