Author Topic: NGUI Performance. Best way to show/hide hundreds of sprites.  (Read 5946 times)

artfabrique

  • Newbie
  • *
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 45
    • View Profile
Hi there.
We need to show/hide 150-200 sprites on mobile at runtime with minimal hickup.
We tried:
- SetActive() for gameobject is slow.
- Move widgets to (20000,20000,0) not working because some widgets are anchored and removing/restoring anchors is slow.

What else can we try?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI Performance. Best way to show/hide hundreds of sprites.
« Reply #1 on: July 29, 2016, 11:09:09 AM »
panel.enabled = false

artfabrique

  • Newbie
  • *
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 45
    • View Profile
Re: NGUI Performance. Best way to show/hide hundreds of sprites.
« Reply #2 on: August 03, 2016, 05:29:11 AM »
panel.enabled = false
The thing is that we have around 500 sprites in a pool: 50 widgets with 10 sprites inside each
This widgets is map markers connected to 3d objects on a global world map.
When user drags/pinch-zoom the map we need to take and release different markers from\to pool.

So we can not just tun off the panel because it's selective operation.
We found that if we set alpha to 0 - NGUI stops to generate mesh. it's an options for us.. but all NGUI components on that widget are still updating (anchors, dimensions) and it eats CPU ms..

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI Performance. Best way to show/hide hundreds of sprites.
« Reply #3 on: August 03, 2016, 09:03:47 AM »
Any change to any widget within a panel causes the panel to rebuild its buffers -- it's to be expected. Setting alpha to 0 and using gameObject.SetActive should be the same thing. In the former, all other scripts attached to the widget will still run, while in the latter they will not.

You can try adding panels to where your widgets are if it's your widgets that are following 3D objects. Moving panels is basically free in NGUI, while moving widgets will cause buffers to be rebuilt. Disabling panels is also effectively free in NGUI when you want to hide them.