Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Docteur Cox on July 16, 2013, 07:25:13 AM

Title: How to check if a widget is visible by UICamera ?
Post by: Docteur Cox on July 16, 2013, 07:25:13 AM
Hello there !

So here's my problem. I have UITables with many widget on each item. While the performances are still decent on my PC (above 150 fps), I would like to make sure it works fine even on low-end machines. I noticed that disabling unseen objects in editor make game considerably faster (250 fps) so I'm looking for a performant way to check whether or not an UIWidget is visible on screen, and if so disable it.

Does someone know how to do that ?

Thanks in advance for your answers !
Title: Re: How to check if a widget is visible by UICamera ?
Post by: ArenMook on July 16, 2013, 10:49:33 AM
UIWidget.isVisible :P
Title: Re: How to check if a widget is visible by UICamera ?
Post by: Docteur Cox on July 17, 2013, 05:40:37 AM
Erf, I just tried that but that does not seem to work for me. All widget are considered to be visible. I also tried UIPanel.isVisible(Widget w) and I get the same output. Do you know what I may have done wrong in my scene ?

Thanks in advance for your answer  :)
Title: Re: How to check if a widget is visible by UICamera ?
Post by: ArenMook on July 17, 2013, 05:52:31 AM
If your panels don't use clipping then the widgets may always be considered to be visible. What I generally do myself is move things off-screen then disable them all in one action. When using ActiveAnimation.Play, you can actually tell it to disable the object after the animation finished playing. If you can't use it, you can still check to see if something is off-screen by checking its rectangle against the screen width/height. NGUIMath.CalculateRelativeWidgetBounds will tell you the rect assuming you use the UI camera's object as parent.
Title: Re: How to check if a widget is visible by UICamera ?
Post by: Docteur Cox on July 18, 2013, 08:48:16 AM
I will try that. Thanks ! :)