当前位置:网站首页>Unity3d:ugui, UI and special effect particle level, bakemesh above 2018.2, particles between two images and in Scrollview
Unity3d:ugui, UI and special effect particle level, bakemesh above 2018.2, particles between two images and in Scrollview
2022-07-23 12:45:00 【Sixi Liyu】
ui The particles shown above generally have two schemes
1. adopt rendertexture Rendering , Can handle hierarchy problems perfectly , But the performance is not good , Multiple cameras
2. Put directly ui Interface adjustment effect sort in layer, But if ui More special effects , The hierarchy is not easy to manage , And more canvas Cause the problem of approval
Now come to the third method, particles BakeMesh( want 2018.2 Above version )
come from Github:https://github.com/mob-sakai/ParticleEffectForUGUI
advantage : Iconicity UGUI You can also adjust the level sorting up and down , Accept Mask Handle
Comparison of various schemes

The particle BakeMesh
principle : Directly let the particle mesh and map in ui Render in the basic components
Use interface
ParticleSystemRenderer.BakeMesh and ParticleSystemRenderer.BakeTrailsMesh Here is the generation grid information
CanvasRenderer.SetMesh
CanvasRenderer.SetTexture
hold mesh and texture Throw to canvasRenderer Rendering
Code parsing
UIParticle
UIParticle Is the parent of the particle
[RequireComponent(typeof(RectTransform))]
[RequireComponent(typeof(CanvasRenderer))]
public class UIParticle : MaskableGraphic
{
protected override void OnEnable()
{
UIParticleUpdater.Register(this);
CanvasRenderer Rendering is included in Canvas Medium UI object , It's a Graphic necessary
UIParticleUpdater
Canvas.willRenderCanvases monitor
internal static class UIParticleUpdater
{
[RuntimeInitializeOnLoadMethod]
private static void InitializeOnLoad()
{
Canvas.willRenderCanvases -= Refresh;
Canvas.willRenderCanvases += Refresh;
}
Q: Canvas.willRenderCanvases monitor
A: Official explanation : At the beginning Canvas Events before rendering .
This allows you to defer processing / Update canvas based elements , Until you're about to start rendering them . Here we do the particle generation Mesh, And then by calling particle.canvasRenderer.SetMesh, Rendered particle mesh
Refresh
private static void Refresh(UIParticle particle)
{
Profiler.BeginSample("[UIParticle] Bake mesh");
BakeMesh(particle);
Profiler.EndSample();
Profiler.BeginSample("[UIParticle] Set mesh to CanvasRenderer");
particle.canvasRenderer.SetMesh(particle.bakedMesh);
Profiler.EndSample();
}

边栏推荐
- C语言:基于顺序表的学生管理系统,超级详细,全部都有注释,看完不懂来扇我。
- 【无标题】
- GameFramework:资源热更代码分析,检查版本信息,下载版本文件,校验版本文件,得到更新文件数量,下载文件,TaskPool
- 关于搭建Hybrid App所需要的基础技术一文
- 《wireshark网络分析就是这么简单》知识点与技巧
- Using one-way linked list to realize queue
- post表单提交数据限制
- Basic knowledge of high voltage technology
- Unity3D高清渲染管线无法在模型上播放视频
- Implementation of heap and heap sorting
猜你喜欢
随机推荐
【无标题】
OSPF和RIP的路由扩展配置
详解TCP连接的释放
Summary of video coding and decoding related data
剖析Redis中的Sentinel模式
主机字节序的判定
Unity3D+moba+技能指示器(一)
OSPF的路由策略和流量抓取
Unity鼠标控制摄像机拖拽、旋转、缩放(模拟编辑器摄像机功能)
详解TCP连接的建立
In depth analysis of replication in redis
即时通讯WebSocket
刷题笔记:二叉树的中序遍历(三种解法-递归,迭代,Morris)
*offer--2
0动态规划 LeetCodde313. 超级丑数
MySQL性能优化,索引优化
详解TCP的交互数据流和成块数据流
Vscode configuration
线程池总结
Implementation of binary tree -c









