Unity UI 优化建议,对官方文档的理解性翻译 (一)

这篇博客探讨了Unity UI的优化策略,包括GPU片段着色器过度使用、CPU重建Canvas批次、合批Canvas次数过多和CPU生成定点等问题。通过分析和优化工具,文章深入解析UI基本概念、常见问题及解决方案,旨在提升Unity UI性能。同时,介绍了Unity UI的源代码开放性,鼓励开发者深入研究源码以优化项目。
摘要由CSDN通过智能技术生成

Unity官方原文https://learn.unity.com/tutorial/optimizing-unity-ui#5c7f8528edbc2a002053b59f

 

1.A guide to optimizing Unity UI

Optimizing a user interface driven by Unity UI is an art. Hard-and-fast rules are rare; instead, each situation must be carefully evaluated with the system’s behavior in mind. The core tension when optimizing any Unity UI is the balancing of draw calls with batching costs. While some common-sense techniques can be used to reduce one or the other, complex UIs must make trade-offs.

 

优化Unity的UI是一门艺术,很少有硬性的规则。而是需要根据系统行为进行仔细地评估。核心问题是如何

平衡DrawCalls和Batch的处理成本。虽然有一些常见的技术手段去减少一种或者另一种的处理成本,但是对于复杂的UI必须进行权衡。

 

However, as is best practice elsewhere, attempts to optimize Unity UIs should begin with profiling. The primary task before attempting to optimize a Unity UI system is to locate the precise reason for an observed performance problem. There are four common classes of problems encountered by users of Unity UI:

  • Excessive GPU fragment shader utilization (i.e. fill-rate overutilization)
  • Excessive CPU time spent rebuilding a Canvas batch
  • Excessive numbers of rebuilds of Canvas batches (over-dirtying)
  • Excessive CPU time spent generating vertices (usually from text)

 

就像优化其它方面一样,UI的优化也要先从分析开始。首要任务是定位产生明显性能问题的确切原因。大多数用户经常遇到的问题可以归为4类:

  • GPU执行了过多的片源着色器(即填充率过度使用,填充率的理解:https://blog.uwa4d.com/archives/fillrate.html
  • CPU花费了大量时间用于合批Canvas(我的理解是单一的Canvas上元素过多)
  • 合批Canvas的次数过多(我的理解是Canvas上的元素频繁变化)
  • CPU花费了大量时间生成定点(通常是文本)

 

It is, in principle, possible to create a Unity UI whose performance is constrained by the sheer number of draw calls being sent to the GPU. However, in practice, any project overloading the GPU with draw calls is more likely to be bound by fill-rate overutilization.

原则上,一个UI的性能受到发送给GPU的DrawCalls数量限制。但是实际运用中GPU因DrawCalls导致超负荷原因可能在于填充率的过度使用。

 

This guide will discuss the fundamental concepts, algorithms and code underlying Unity UI as well as discussing common problems and solutions. It is broken into five chapters:

  1. The Fundamentals of Unity UI chapter defines terminology specific to Unity UI and discusses the details of many of the fundamental processes performed to render the UI, including the building of batched geometry. It is strongly recommended that readers begin with this chapter.
  2. The Unity UI profiling tools chapter discusses gathering profiling data with the various tools available to developers.
  3. The
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值