Author Topic: Performance of Complex Gui  (Read 4628 times)

MadDave

  • Guest
Performance of Complex Gui
« on: September 11, 2012, 12:35:05 PM »
Hi,

we have a fairly complex Gui and are running into performance issues on iOS now. I hope that some of you guys have ideas or experience how to optimize it.

The Gui is basically an inventory system with many slots for items and all kinds of labels and info windows. Problem seems to be that we frequently need to show or hide widgets and we do it with GameObject.SetActiveRecursively(). This causes massive slowdowns.

UIPanel.LateUpdate() takes up to 350ms on an iPad3 which is completely unacceptable.

Something we already figured out is that a large number of colliders getting activated or deactivated (when the whole inventory window is shown/hidden) causes a massive spike in the physics system. We added rigid body components to all widgets and that helped.

So, what can we do? Use more and smaller UIPanels? Show/Hide widgets in a better way?

Thanks!
David

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Performance of Complex Gui
« Reply #1 on: September 11, 2012, 12:52:02 PM »
A widget changing means that the panel's buffer must be rebuilt. The less stuff you have on the panel where something is changing, the better the performance. I also suggest using NGUITools.SetActive instead of GameObject.SetActiveRecursively btw. It activates objects in a proper order.

Unisip

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: Performance of Complex Gui
« Reply #2 on: December 31, 2012, 06:22:32 AM »
Reopening this performance thread: i'm getting the same perf issue due to colliders.

Just out of curiosity: Michael, have you considered at some point skipping physics altogether? At least for a 2d only interface, physics cost seems overkill --> it's fairly easy to raycast in 2d on a set of quads. I'm considering modifying ngui to support that, at least for my complex interface needs.
Before i embark on that, I'd appreciate any thoughts you might have about this...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Performance of Complex Gui
« Reply #3 on: December 31, 2012, 06:53:49 AM »
I hear putting more rigidbodies into the UI helps with the physics. Unity can be strange sometimes.

No, I haven't delved into that. I wanted NGUI to support mesh colliders, not just squares. The Unity's upcoming UI does its own hit detection logic though! ;)