Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: afroman on January 28, 2014, 02:03:48 PM
-
I'm having serious performance issues in UIRect.Start() & UIPanel.LateUpdate(). I have a lot of labels in my UI that can be disabled & enabled depending on whether or not the shop is open. This is causing over 1.4MB of GC. This is really hurting performance in my game, any suggestions?
-
It seems that you Destroy and Instantiate the items whenever you hide/show them because .Start() is only called once foreach Component.
You should recycle the GameObject :
- When you want to hide an item, don't destroy it, disable the GameObject and keep the reference in a Queue
- When you need to show an item, pop an item in your Queue, update the parameters (label text, sprits) and enable it.
- If the Queue is empty and you need an item, just instantiate it. You can also pre instantiate as many items as you need at the start of the game.
-
I do. I don't destroy objects knowing that I will use it again.
I'm actually disabling the GameObjects that I don't use after initially instantiating them. It is however still a problem when I re-enable the same GameObjects again. I'm getting a whopping 3.7MB In garbage collection in UIRect.OnEnable(). Which is causing the game to run really slow, each time the shop is open.
I doubt it but would using a Queue still help with this issue? Or would this be a general GC issue I need to work around?
-
Do you have the last version of NGUI ? Arenmook fixed some performance issues.
I see that there is 361 calls to GameObject.Activate, do you have 361 objects in your list ?
Do you really need to disable all those objets ? Can't you just disable/enable the panel when closing/opening the shop ?
-
Yes, I am disabling all 361 GameObjects. I'm also on the latest version 3.09.
I was disabling the GameObjects because it seemed like the only logical thing to do.
Good idea thou, I'll try that.
Thanks, I'll let you know how it goes :)
-
it's fixed, significant performance improvements!
-
Facing the same issue here, but just disabling the panel brings back the old Unity 3 issue, enabled-state is not inherited :) So this solution is not really doable for nested panels, if you don't want to manually keep track of the state... (you don't). Still gotta try out the latest version of NGUI for potential performance-gains (currently on 3.5.1 waiting for 3.5.6), but yeah inherited enabled-state of panels would be great ;) (but may break to much for current users..?).
-
Instead of disabling the Panel component, you should probably disable the gameobject - then it should be inherited.
-
Instead of disabling the Panel component, you should probably disable the gameobject - then it should be inherited.
Well of course, but that will cause massive spikes (as you talked about above) when activating a gameObject with a large number of widgets. :(
I'm on Unity 4 so yes the state is inherited, but activating a parent will then cause all child-widgets to invoke UIRect.OnEnable = partypooper.