diff --git a/Scripts/UIParticleUpdater.cs b/Scripts/UIParticleUpdater.cs index 0f78156..1428407 100755 --- a/Scripts/UIParticleUpdater.cs +++ b/Scripts/UIParticleUpdater.cs @@ -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(); + 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(); if (CanBakeMesh(r)) { Profiler.BeginSample("[UIParticle] Bake Mesh > Bake Main Particles"); diff --git a/Scripts/Utils.cs b/Scripts/Utils.cs index ebc4278..87e9fa5 100644 --- a/Scripts/Utils.cs +++ b/Scripts/Utils.cs @@ -194,8 +194,12 @@ namespace Coffee.UIParticleExtensions var bRenderer = b.GetComponent(); // 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;