SmartlyDressedGames / Unturned-3.x-Community

Community portion of the Unturned-3.x repo. If you have access to the source code you can find it here:
https://github.com/SmartlyDressedGames/Unturned-3.x/
83 stars 17 forks source link

EffectManager FPS Improvement #4442

Closed QERT2002 closed 1 week ago

QERT2002 commented 2 weeks ago

ReceiveUIEffectText - add new arg bool CheckOnlyEnabled = false ReceiveUIEffectImageURL - add new arg bool CheckOnlyEnabled = false ReceiveUIEffectVisibility - add new arg bool CheckOnlyDisabled = false

Currently, Transform transform = value.transform.FindChildRecursive(childName); -> this method check all transforms. And in very complex UI effects, where there is a complex hierarchy, this method iterates through absolutely all game objects. This causes a fairly noticeable drop in FPS in the moment.

I propose to add an additional parameter to the existing methods, with a preset value of false, so that plugin creators can optionally force the game code to check only active gameobjects. This small and non-global change will allow plugin developers to currently optimize work with large UI effects. Best regards, QERT2002.

SDGNelson commented 2 weeks ago

How many game objects are in your effect?

Admittedly not straightforward, but did you run the profiler suggesting this is a bottleneck?

Nowadays I would probably have the RPC provide the relative path e.g. "container/button/label" rather than just "label".

QERT2002 commented 2 weeks ago

How many game objects are in your effect?

Admittedly not straightforward, but did you run the profiler suggesting this is a bottleneck?

Nowadays I would probably have the RPC provide the relative path e.g. "container/button/label" rather than just "label".

About 1000-1500 gameobjects. I didn’t run the profiler, but when updating tiles (with item names, pictures and prices) that are at the end of the hierarchy, the FPS drops by 50-65 at the moment the button is clicked. If you raise the panel with objects to the very top of the hierarchy, FPS drops by 5-10. image

SDGNelson commented 2 weeks ago

That's quite something.

For the next update I'll change childName into childNameOrPath so you can provide the path to the item you want to modify.