Author Topic: ScrollView Image Gallery with 100s of Runtime Images [Performance]  (Read 2463 times)

amraffay

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 37
    • View Profile
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  :)

Agent_007

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 5
  • Posts: 27
    • View Profile

amraffay

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 37
    • View Profile
Re: ScrollView Image Gallery with 100s of Runtime Images [Performance]
« Reply #2 on: May 07, 2015, 10:05:25 AM »
I believe this is much complex problem than WrapContent as we have to handle images somehow.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: ScrollView Image Gallery with 100s of Runtime Images [Performance]
« Reply #3 on: May 07, 2015, 05:22:05 PM »
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.

amraffay

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 37
    • View Profile
Re: ScrollView Image Gallery with 100s of Runtime Images [Performance]
« Reply #4 on: May 07, 2015, 10:54:04 PM »
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

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: ScrollView Image Gallery with 100s of Runtime Images [Performance]
« Reply #5 on: May 09, 2015, 04:13:57 AM »
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.