Why Does Reducing Health Bar Vertices Fail to Improve UGUI Performance in Unity?
Why Does UI Processing Time Drop Significantly When Health Bars Are Hidden, but Not When Their Vertex Counts Are Reduced?
Based on the current comparison results, health bar components are a significant source of performance overhead. However, the issue is more likely related to mesh generation frequency and its CPU cost than to the number of vertices. https://uwa overseas public.oss us east 1.aliyuncs.com/uploads/markdown/1878d547 32f0 43c8 ad28 3740b402de2d.png In the GameOptim GOT Online report, UGUI related processing time reaches 20–30 ms in some frames. Hiding health bars reduces several types of overhead simultaneously, including UI updates, mesh rebuilding, and Canvas batching. Reducing the vertex count mainly decreases the amount of data processed during each mesh generation operation, but does not reduce the number of mesh rebuilds. As a result, the overall processing time may show little improvement. https://uwa overseas public.oss us east 1.aliyuncs.com/uploads/markdown/06b6a918 e9b9 4520 ac85 9e8dd1275287.png The custom function is called approximately 77 times per frame on average, reaching 259 calls in some frames, with a corresponding CPU cost of 5.91 ms. This indicates that mesh generation for the custom has become a noticeable source of CPU overhead. However, frequent calls do not necessarily indicate unnecessary updates. They may also result from a large number of health bars legitimately generating meshes within the same frame. To investigate, use the Unity Profiler to inspect calls to , , and the custom function. Focus on the following areas: Whether unnecessary calls to or are occurring. Whether health values, fill ratios, and colors are being reassigned repeatedly even when their values have not changed. Whether the number of health bars updated in a single frame matches actual requirements. If related operations such as also have high processing costs, consider separating dynamic health bars from static UI elements. Note that splitting Canvases can reduce the impact of dynamic updates on other UI elements, but it does not reduce the mesh generation cost of an individual . After optimization, compare the following metrics: UGUI related CPU processing time. Total processing time of . Number of mesh rebuilds. If processing time decreases but total UGUI processing time changes little, continue investigating Canvas batch rebuilding and other UI update operations.