Author Topic: NGUI: CPU/GPU usage  (Read 3246 times)

chenmark

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
NGUI: CPU/GPU usage
« on: May 21, 2014, 12:55:07 AM »
Hello,

Got some questions about NGUI:
* Can you specify what approach was implemented in NGUI for tracking the basic widget state changes such as user input.
* Are you using an event driven approach or is it a polling approach?
* If its a polling approach, is there any tips to minimize idle overhead?
* Is there a way to specify an interval longer than once every frame for specific things?
* When objects are culled, does NGUI automatically pause the polling?
* Is there a way like in DFGUI to set an object as not interactive thus not running any polling?
* How complex is it to override the polling implementation in favor to a pure event-driven?   

Thanks
Chen

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: NGUI: CPU/GPU usage
« Reply #1 on: May 21, 2014, 02:24:41 AM »
Widget state changes is a different thing than user input. The state is maintained in that nothing changes from Update to Update unless you initiate or cause the change. In that manner, the UI sate is persistent.

Input is based on UICamera, which in Update checks Input.touchCount (and similar for other input methods) and then notifies the collider that's been hit by the input. So I suppose it's sort of a hybrid of polling and event based, as the raw input is taken through polling, while further input handling is propagated out to only the relevant widgets/colliders.

Right now you can't limit how often it polls and for performance reasons it's not needed anyway - it's just doing a for loop of up to 10 touches + mouse + joystick/controller, and when those inputs are not there, it's just a skipped for loop. (See UICamera:Update() for details).

Nothing is interactive unless there's a collider on it, so if you remove the collider, it's not interactive.

As far as I know, you can't change it out to completely event driven since unity doesn't have any events that get fired when input is registered, but it is a close as you can get.

chenmark

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: NGUI: CPU/GPU usage
« Reply #2 on: May 21, 2014, 02:56:24 AM »
Thanks that cleared it out.