ReactUnity / core

React and HTML framework for Unity UI & UIToolkit
https://reactunity.github.io/
MIT License
723 stars 38 forks source link

[UGUI] Performance Improvement to not create GameObjects that are empty #77

Closed Muchaszewski closed 1 year ago

Muchaszewski commented 1 year ago

If a component does not have anything, do not spawn it. Eg: [Shadows] or [BorderImage]. It should improve reload/update speed significantly. image

The rate at which new GameObjects are added is connected directly to the about of said game objects on the scene and their hierarchy. From my tests in the past, creating a Single "Empty Object" on a scene with 2500 objects can be around 1-2ms on a mid-low end PC (slower on mobile). Adding MonoBehaviour has a similar performance effect but 1/4 the penalty.

This can be part of Pooling behavior, to not spawn objects when they would be needed they can should be quickly taken from a pool. But be aware, that changing the rendering order (enable/disable GO included) forces Canvas to re-render the whole path to the next Canvas.

image image

KurtGokhan commented 1 year ago

Improved in v0.14.0