Author Topic: Scroll View Lag?  (Read 2636 times)

Majicpanda

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 83
    • View Profile
Scroll View Lag?
« on: February 27, 2014, 08:22:55 PM »
This is potentially my fault due to poor design, but I have a scroll view that holds an inventory system.  The inventory can hold up to 100 items, so what Ive done is create 100 prefab instances that can contain all of the slots and the ones I don't need I make completely inactive.  When scrolling the list it lags horribly unless I delete all the way down to about 20 items.

Is there something with scroll lists that I might need to look for when containing a large number of prefabs within?

rain

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 79
    • View Profile
Re: Scroll View Lag?
« Reply #1 on: February 28, 2014, 08:45:44 AM »
You should try to minimize the amount of prefab instances in the scrollviews by making your own pooling logic.

Majicpanda

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 83
    • View Profile
Re: Scroll View Lag?
« Reply #2 on: February 28, 2014, 03:30:28 PM »
That's kind of the problem... the UIInventory prefabs are pre-pooled into the system, it's not like I'm instantiating and destroying anything as they come in and out of the clipped area.  I don't see how you're supposed to take 100 inventory items the player owns and set a scrollable list unless you somehow only use 20 prefabs and on scrolll in and out of the clip you change what item the UIInventory prefab is pointing at.. which sounds a bit crazy.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scroll View Lag?
« Reply #3 on: February 28, 2014, 05:53:26 PM »
By default, the scroll view's panel will not cull its content as you're dragging stuff, so while you are dragging the scroll view, you are drawing all 100 of your items. This actually improves performance over culling, as you don't need to do any additional math checks to see if something is visible or not. Scroll view's content buffers are also not changing while scrolling. However if you have a scroll bar, it will be changing, which will also cause the panel it's on to re-create its buffers, which is expensive. This is why I placed the scroll bar underneath its own panel in the scroll view example.