Unity性能优化笔记——UI优化

NGUI:

cs 复制代码
public class UIGeometry
{
   public BetterList<Vector3> verts = new BetterList<Vector3>();
   public BetterList<Vector2> uvs = new BetterList<Vector2>();
   public BetterList<Color32> cols = new BetterList<Color32>();
   public BetterList<<Vector3> mRtpVerts = new BetterList<Vector32>();
}

UGUI:

cs 复制代码
public class VertexHelper:IDisaposable
{
   private List<Vector3> m_Positions = ListPool<Vector3>.Get();
   private List<Color32> m_Colors = ListPool<Color32>.Get();
   private List<Vector2> m_Uv0s = ListPool<Vector2>.Get();
   private List<Vector2> m_Uv1s = ListPool<Vector2>.Get();
   private List<Vector3> m_Normals = ListPool<Vector3>.Gte();
   private List<Vector4> m_Tangents = ListPool<Vector4>.Get();
   private List<int> m_Indices = ListPool<int>.Get();
}

元素更新方式:

NGUI:

UIPanel.LateUpdate

1.轮询

2.UIPanel.UpdateWidgets

UGUI:

Canvas.SendWillRenderCanvas

1.队列

2.m_LayoutRebuildQueue

3.m_GraphicRebuildQueue

UGUI如果Canvas没有变化Canvas.SendWillRenderCanvas是完全没有开销的

处理隐藏显示元素方式

NGUI:

1.大量的SetActive(false),

2.适量的Color.a = 0 ,移出

3.Time + 二级缓存

UGUI

1.scale = 0,Alpha Group = 0

修改一个UI元素最终会转变成很多组的顶点属性,同过这些顶点属性转换成mesh。动态的UI元素要控制数组里面的顶点数。

对于制作的影响:

1."动态"元素尽量少用OutLine.Tiled Sprite。

2.尽量减少"动态"长文本。

待补充。。。

相关推荐
玖玥拾18 分钟前
Unity 3D 笔记(十一)UI 框架进阶:栈弹窗交互、BasePanel 基类虚方法、DoTween 界面动画
笔记·3d·unity
郝学胜-神的一滴2 小时前
中级OpenGL教程 023:Assimp模型加载全解——从源码到架构的骈文探秘
c++·unity·游戏引擎·cmake·unreal engine·opengl
xcLeigh20 小时前
Unity基础:GameObject与Component——Unity核心架构思想彻底理解
unity·教程·component·gameobject
郝学胜-神的一滴1 天前
中级OpenGL教程 022:探秘三维世界的血脉传承——物体父子关系与矩阵递归奥义
c++·线性代数·unity·矩阵·游戏引擎·unreal engine·opengl
weixin_424294672 天前
Unity的测试Edit Mode和Play Mode,有什么区别?
unity
玖玥拾2 天前
Unity 3D 笔记(八)ScrollRect 滚动视图、NavMesh 自动寻路系统
笔记·3d·unity
淡海水3 天前
06-04-YooAsset源码-Unity加密解密服务
前端·unity·性能优化·c#·游戏引擎·yooasset
cd_949217213 天前
Unity游戏角色资产怎么快速制作?用V2Fun跑通生成、绑定和导入测试
游戏·unity·游戏引擎