UI 和 UI Details Profiler 模块提供有关 Unity 在应用程序内布局和渲染用户界面方面花费的时间和资源的信息。使用此模块可以了解 Unity 如何为应用程序处理 UI 批处理,包括 Unity 为何以及如何对对象进行批处理。使用此模块还可以查明 UI 的哪一部分导致性能下降,或者在拖动时间轴的同时预览 UI。
有关如何使用 Profiler 窗口的更多信息,请参阅 Profiler 窗口入门相关文档。
UI 和 UI Details Profiler 模块的图表被分为五个类别。要更改图表中类别的顺序,可以在图表的图例中拖放这些类别。还可以单击某个类别的有色图例以切换是否显示。
图表 | 描述 | |
---|---|---|
UI Profiler 模块 | ||
Layout | Unity 在执行 UI 的布局通道方面花费的时间。这包括 HorizontalLayoutGroup、VerticalLayoutGroup 和 GridLayoutGroup 进行的计算。 | |
Render | UI 在完成渲染部分中花费的时间。这是直接渲染到图形设备的成本,或者是渲染到主渲染队列的成本。 | |
UI Details Profile 模块 | ||
Batches | 显示一起批处理的绘制调用的总数。 | |
Vertices | 用于渲染 UI 某个部分的顶点总数。 | |
Markers | 显示事件标记。用户与 UI 交互(例如,单击按钮或更改滑动条值)时,Unity 将记录标记,然后将它们绘制为图表上的垂线和标签。 |
选择 UI 或 UI Details Profiler 模块时,Profiler 窗口底部的模块详细信息面板会显示应用程序中 UI 的更多相关详细信息。据此可以检查应用程序中 UI 对象的相关性能分析信息。该面板被分为以下几列:
列 | 描述 |
---|---|
Object | 应用程序在性能分析期间使用的 UI 画布的列表。双击一行可以突出显示场景中的匹配对象。 |
Self Batch Count | Unity 为画布生成的批次数量。 |
Cumulative Batch Count | Unity 为画布及其所有嵌套画布生成的批次数量。 |
Self Vertex Count | 此画布渲染的顶点数量。 |
Cumulative Vertex Count | 此画布和嵌套的画布渲染的顶点数量。 |
Batch Breaking Reason | Unity 拆分此批次的原因。有时 Unity 可能无法对对象同时进行批处理。常见原因包括: 不与画布共面 (Not Coplanar With Canvas):批处理需要对象的矩形变换与画布共面(未旋转)。 画布注入索引 (CanvasInjectionIndex):CanvasGroup 组件存在并强制新建批次,例如在其余部分上显示一个组合框的下拉列表时。 不同的材质实例、矩形裁剪、纹理、A8 纹理用法 (Different Material Instance, Rect clipping, Texture, or A8TextureUsage):Unity 只能将具有相同材质、遮罩、纹理和纹理 Alpha 通道用法的对象一起进行处理。 |
GameObject Count | 此批次中包含的游戏对象数量。 |
GameObjects | 批次中的游戏对象的列表。 |
从列表中选择 UI 对象时,对象的预览将显示在面板右侧。预览上方的工具栏中有以下选项:
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.