feat: ignore rendering of particle systems that do not have a SharedMaterial and TrailMaterial

Close #118
pull/120/head
mob-sakai 2020-11-20 10:44:17 +09:00
parent 44889c8a33
commit 08c4aba8ab
2 changed files with 8 additions and 3 deletions

View File

@ -164,6 +164,8 @@ namespace Coffee.UIExtensions
// No particle to render.
var currentPs = particle.particles[i];
if (!currentPs || !currentPs.IsAlive() || currentPs.particleCount == 0) continue;
var r = currentPs.GetComponent<ParticleSystemRenderer>();
if (!r.sharedMaterial && !r.trailMaterial) continue;
// Calc matrix.
Profiler.BeginSample("[UIParticle] Bake Mesh > Calc matrix");
@ -218,7 +220,6 @@ namespace Coffee.UIExtensions
#endif
// Bake main particles.
var r = currentPs.GetComponent<ParticleSystemRenderer>();
if (CanBakeMesh(r))
{
Profiler.BeginSample("[UIParticle] Bake Mesh > Bake Main Particles");

View File

@ -194,8 +194,12 @@ namespace Coffee.UIParticleExtensions
var bRenderer = b.GetComponent<ParticleSystemRenderer>();
// Render queue: ascending
var aMat = aRenderer.sharedMaterial;
var bMat = bRenderer.sharedMaterial;
var aMat = aRenderer.sharedMaterial ?? aRenderer.trailMaterial;
var bMat = bRenderer.sharedMaterial ?? bRenderer.trailMaterial;
if (!aMat && !bMat) return 0;
if (!aMat) return -1;
if (!bMat) return 1;
if (aMat.renderQueue != bMat.renderQueue)
return aMat.renderQueue - bMat.renderQueue;