Author Topic: When should I start putting Widgets in their own UIPanels?  (Read 5387 times)

Prodigga

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 17
    • View Profile
When should I start putting Widgets in their own UIPanels?
« on: September 24, 2014, 03:08:53 AM »
Hey guys,

So I have a much better understanding of how NGUI does batching and how panels work. From what I've read, resizing/moving panels is cheaper than widgets, because the widgets will rebuild the mesh if you move/rotate/scale them.

I've got a panel with a scroll view. Underneath it is 3 UIWidgets which are 3 pages of data (They contain some labels, etc). You navigate these pages by swiping side to side.

All of this is 1 draw call because I only use a single UIPanel. But would it be better to break up each page into its own sub-panel? The scroll view is scrolling those 3 UIWidgets - from what I understand, this means that the panel must regenerate the mesh of all its children because those widgets are now moving? Is this correct? If the contents of those 3 widgets was static, and I made them UIPanels instead, then NGUI won't have to regenerate the meshes?

-UIPanel (+Scroll view)
--UIWidget
---*Labels, etc*
--UIWidget
---*Labels, etc*
--UIWidget
---*Labels, etc*

vs

-UIPanel (+Scroll view)
--UIPanel
---*Labels, etc*
--UIPanel
---*Labels, etc*
--UIPanel
---*Labels, etc*


Edit:

Or would this make a difference?

-UIPanel (+Scroll view)
--UIPanel
---UIWidget
----*Labels, etc*
--UIPanel
---UIWidget
----*Labels, etc*
--UIPanel
---UIWidget
----*Labels, etc*

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: When should I start putting Widgets in their own UIPanels?
« Reply #1 on: September 24, 2014, 01:57:36 PM »
Scroll view movement doesn't cause widget buffers to be re-generated unless widgets go in or out of view, which doesn't happen every frame. Scrolling is generally pretty efficient.

Prodigga

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 17
    • View Profile
Re: When should I start putting Widgets in their own UIPanels?
« Reply #2 on: September 24, 2014, 10:06:00 PM »
Ok good to know! What if instead the UIWidgets were all rotating? Then it would be better to make them panels right? What about scaling? Or using the UITween position instead of scrolling them? Do all those cause the parent panel to rebuild the meshes?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: When should I start putting Widgets in their own UIPanels?
« Reply #3 on: September 25, 2014, 07:06:11 PM »
Moving, scaling or rotating panels = efficient.
Moving, scaling or rotating widgets = not efficient.

Prodigga

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 17
    • View Profile
Re: When should I start putting Widgets in their own UIPanels?
« Reply #4 on: September 28, 2014, 08:51:23 PM »
Thanks, thats just what I thought.

Ok just one more question. I am assuming you use vertex colors to tint the widgets different colors. Does this mean that in the following example:

-UIPanel (+Scroll view)
--UIWidget
---*Labels, etc*
--UIWidget
---*Labels, etc*
--UIWidget
---*Labels, etc*

If I was the change the "color" of one of the widgets, the entire UIPanel will rebuild?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: When should I start putting Widgets in their own UIPanels?
« Reply #5 on: September 29, 2014, 07:17:12 AM »
Correct. Perhaps I should have said any change done to widgets will cause the draw buffers to be rebuilt.

andreyd

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 18
    • View Profile
Re: When should I start putting Widgets in their own UIPanels?
« Reply #6 on: October 02, 2014, 03:13:29 PM »
I did quite a few performance testing myself. We use clipped panels with a lot of widgets that go in and out of panel's clipping rectangle. I found that if your cell (UIWidget that contains other widgets) has more than 3-4 UIRects that it needs to update, this layout works a lot better:


-UIPanel (+Scroll view)
--UIPanel
---UIWidget
----*Labels, etc*
--UIPanel
---UIWidget
----*Labels, etc*
--UIPanel
---UIWidget
----*Labels, etc*