Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: alexh0101 on April 14, 2015, 09:59:30 AM

Title: Performance drop on first time a UIButton is clicked in a scene
Post by: alexh0101 on April 14, 2015, 09:59:30 AM
When my scene start and I press a UIButton for the first time, I get a 178ms lag.

In the Profiler, I see this:

(http://www.tasharen.com/forum/index.php?action=dlattach;topic=12904.0;attach=5923;image)

But when I collapse the "UIButton.onClick", nothing appears with that 178ms.

Why is that happening?
If this is mandatory, is there a way to initialise whatever has to be initialised, while the scene is loading?
Title: Re: Performance drop on first time a UIButton is clicked in a scene
Post by: ArenMook on April 16, 2015, 05:28:02 AM
Try a deep profile to further narrow down the culprit. All UIButton.OnClick does is calls whatever delegate you've set.
Title: Re: Performance drop on first time a UIButton is clicked in a scene
Post by: Nicki on April 19, 2015, 08:31:12 AM
Yeah, follow it deeper down. It's likely whatever you have set the game to do when you click. Say if you have a button "load new scene" then the stack trace will start at the UICamera, then to the button and further down until you get to the real culprit (loading a scene).