Author Topic: Optimisation Question - UIPanel.LateUpdate  (Read 3961 times)

AssyriaGameStudio

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Optimisation Question - UIPanel.LateUpdate
« on: June 19, 2015, 06:19:18 AM »
Hey,
so; first off thanks for all the help in the previous threads ArenMook, it's been really helpful in getting me up to speed with NGUI.

Now onto the new question... I'm running into one small optimisation issue with UIPanel.LateUpdate in that my structure is as follows:

Parent(UIPanel)
-- Side Bar(UIPanel)
--- Lots of items here (UI Widgets and some Panels)
-- Main Screen(UIPanel)
--- Some Page(UIPanel)
---- Lots of items here (UI Widgets and some Panels)
--- Some Page(UIPanel)
---- Lots of items here (UI Widgets and some Panels)
--- Some Page(UIPanel)
---- Lots of items here (UI Widgets and some Panels)

This basically is a mobile sidebar whereby it comes in from the left, with the main screen moving right to accommodate. Anyway I'm tweening the Parent UIPanel to move it all over when the side bar is toggled.

Having searched the forum it seemed to suggest that each UIPanel would batch it's child objects into a mesh / single drawcall, so I structured it with lots of UI panels where by I accepted the increased drawcall count assuming if I moved the "Parent" UIPanel, it would only have to move the child UIPanels without really needing to update anything / much of a performance cost.

Unfortunately when I'm tweening the Parent, despite this structure, I'm still getting some a noticeable performance hit... All that's happening during this hike in UIPanel.LateUpdate is that the single parent object is being tweened; so it leads me to assume I'm doing something wrong in terms of the structure.

My question being - what should I be doing differently?

(p.s. I know I have more in UIRect.Update than I need to / am in the process of going thru and turning all the ones suitable to OnEnable).
« Last Edit: June 21, 2015, 09:27:28 AM by AssyriaGameStudio »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Optimisation Question - UIPanel.LateUpdate
« Reply #1 on: June 21, 2015, 07:58:12 PM »
UIRect.Update is where anchors get updated. Do you have anchored elements? Keep in mind updating anchored elements requires quite a bit of math, and often marks the panel as changed due to floating point imprecision.

AssyriaGameStudio

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: Optimisation Question - UIPanel.LateUpdate
« Reply #2 on: June 23, 2015, 10:48:47 AM »
I have anchored elements, however in terms of trying to minimize impact on UIPanel.LateUpdate I'm anchoring only within a given panel and (now) the majority of anchoring is done only on start / triggered in code as a one-off only when needed.

However I'm still getting a serious UIPanel.LateUpdate performance hit when tweening the UIPanel that's the parent of all the others.

AssyriaGameStudio

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: Optimisation Question - UIPanel.LateUpdate
« Reply #3 on: June 23, 2015, 09:24:33 PM »
This is where I'm at now... All the UIRect.Update costs are negligible / most things are only updated when needed.

The issue I'm running into is UIPanel.LateUpdate sucking up a lot of performance both:
- When moving the parent transform of all the "screens" in order to show the side bar.
- When re-populating a UIScrollList (with items that are already in the scene; just swapping them in/out and repositioning the table).

So basically I could just do with some tips as to scene structure in terms of ensuring UIPanel.LateUpdate doesn't have quite so much to do when a single parent / few transforms are just being moved or tweened.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Optimisation Question - UIPanel.LateUpdate
« Reply #4 on: June 25, 2015, 08:44:28 PM »
Find UIWidget.UpdateTransform and remove "mMoved = true" around line 1415. After this panel being moved should have less effect on performance. Mark the panels as "static" for an even greater boost.

Note that repopulating a scroll list will still hit your performance. You may not be creating things, but you are causing draw calls to be rebuilt when you add stuff to panels. This hits your performance.

AssyriaGameStudio

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: Optimisation Question - UIPanel.LateUpdate
« Reply #5 on: June 25, 2015, 10:02:01 PM »
That did the trick!

Awesome, thanks :).