Author Topic: Best way to create masses of panels  (Read 5381 times)

Samhayne

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Best way to create masses of panels
« on: February 03, 2014, 04:50:26 PM »
Hey,

so... we have indicators above our enemies
showing name, health, magic, symbols for active spells...

There could very well be 50 or more that need to be drawn.

What's the most performant structure for this?

- Having one panel and add one gameobject parent per indicator
containing sprites, labels, etc and we just move the indicator around by
moving the parenting gameobject?

- Having loads of UiPanels marking it with widgetsAreStatic and move those
panels around

- ...?

tylocook

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Best way to create masses of panels
« Reply #1 on: February 03, 2014, 09:38:42 PM »
Seems to me it would make more sense to have 1 panel and move the widgets around. So your first idea sounds good to me.

50 isn't that many, in my opinion. It's when you get close to 1000+ that you start to have a problem.

Yukichu

  • Full Member
  • ***
  • Thank You
  • -Given: 3
  • -Receive: 8
  • Posts: 101
    • View Profile
Re: Best way to create masses of panels
« Reply #2 on: February 03, 2014, 10:36:14 PM »
50 objects above the heads of 1 player...

20 players = 1000 objects.  If I am understanding this correctly...

I would try to make it a panel-per-player and move the panel around, but that's just my intuition.  I have nothing concrete other than 'it makes sense to me to do this.'

Samhayne

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: Best way to create masses of panels
« Reply #3 on: February 04, 2014, 12:23:20 AM »
Tried it with a standard UiPanel as parent... the performance was awful.
5fps with 200-300 panels with a sprite each.
Having loads of panels seems to be a real issue...

I removed the panel and just parented them under a gameobject.
Performance was better (80fps)... but dropped quickly when adding another
sprite and a label.

The fact that these panels/gameobjects move around all the time seems to
kill NGUI.

I hope there is a recipe for this problem.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Best way to create masses of panels
« Reply #4 on: February 04, 2014, 02:57:02 AM »
Having that many panels is a bad idea.

I suggest 1 panel for your entire HUD. If the HUD is going to be changing frequently anyway, having many panels won't yield any benefit.

Now, if the HUD won't be changing much, then yes having one panel per object that actually does move will improve performance. Panels are optimized to be moved efficiently. One panel managing several non-changing widgets = fast.

Also, make sure you have the latest version of NGUI. NGUI 3.0.8 had a lot of performance optimizations.