Author Topic: UIScrollView optimization  (Read 1847 times)

ryan

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 90
    • View Profile
UIScrollView optimization
« on: February 18, 2014, 05:02:55 PM »
I have a use case where UIScrollView.LateUpdate is taking about 20ms to run on an iPad 2.  Part of the problem is that I have way too many widgets in the scroll view, but the other part is that one of its children has a pulsing color, causing UIScrollView to recalculate the bounds of its children every frame.  It's deciding whether to change the alpha on the scroll bars, but there are no scroll bars.  I've locally changed this line near the top of LateUpdate:

      if (showScrollBars != ShowCondition.Always)

to this:

      if (showScrollBars != ShowCondition.Always && (verticalScrollBar || horizontalScrollBar))

I can also change showScrollBars to Always on my prefab, but that's too easy.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIScrollView optimization
« Reply #1 on: February 19, 2014, 12:14:24 PM »
The change seems fine to be, but the real problem is that changing a widget means changing the draw call's geometry, which is the slowest thing that can happen in NGUI. I'd remove the "pulsing" effect. At the very least make it not do anything if it's not visible.