fix: add meshCleared flag to optimize mesh clearing

This commit is contained in:
Minhyuk Kim
2026-04-08 16:55:51 +09:00
committed by mob-sakai
parent d89d394e04
commit 859fa20d29

View File

@@ -30,6 +30,7 @@ namespace Coffee.UIExtensions
private int _index; private int _index;
private bool _isPrevStored; private bool _isPrevStored;
private bool _isTrail; private bool _isTrail;
private bool _meshCleared;
private Bounds _lastBounds; private Bounds _lastBounds;
private Material _materialForRendering; private Material _materialForRendering;
private Material _modifiedMaterial; private Material _modifiedMaterial;
@@ -285,10 +286,14 @@ namespace Coffee.UIExtensions
|| (_isTrail && !_particleSystem.trails.enabled) // Trail, but it is not enabled. || (_isTrail && !_particleSystem.trails.enabled) // Trail, but it is not enabled.
) )
{ {
// Skip clearing the mesh if it's already cleared.
if (_meshCleared) return;
Profiler.BeginSample("[UIParticleRenderer] Clear Mesh"); Profiler.BeginSample("[UIParticleRenderer] Clear Mesh");
workerMesh.Clear(); workerMesh.Clear();
canvasRenderer.SetMesh(workerMesh); canvasRenderer.SetMesh(workerMesh);
_lastBounds = new Bounds(); _lastBounds = new Bounds();
_meshCleared = true;
Profiler.EndSample(); Profiler.EndSample();
return; return;
@@ -312,6 +317,7 @@ namespace Coffee.UIExtensions
// customData.SetVector(ParticleSystemCustomData.Custom2, 3, 0); // customData.SetVector(ParticleSystemCustomData.Custom2, 3, 0);
// } // }
_meshCleared = false;
var main = _particleSystem.main; var main = _particleSystem.main;
var scale = GetWorldScale(); var scale = GetWorldScale();
var psPos = _particleSystem.transform.position; var psPos = _particleSystem.transform.position;