From 2ec81da04877d63593dd863133b6da149dcd79e6 Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Fri, 20 Nov 2020 11:34:44 +0900 Subject: [PATCH] fix: the particles may disappear unintentionally Close #117 --- Scripts/UIParticle.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Scripts/UIParticle.cs b/Scripts/UIParticle.cs index 004b416..7b20ad9 100755 --- a/Scripts/UIParticle.cs +++ b/Scripts/UIParticle.cs @@ -245,12 +245,7 @@ namespace Coffee.UIExtensions if (count == 0 || !isActiveAndEnabled || particles.Count == 0) { canvasRenderer.Clear(); - - foreach (var m in s_PrevMaskMaterials) - StencilMaterial.Remove(m); - - foreach (var m in s_PrevModifiedMaterials) - ModifiedMaterial.Remove(m); + ClearPreviousMaterials(); return; } @@ -293,11 +288,18 @@ namespace Coffee.UIExtensions } } + ClearPreviousMaterials(); + } + + private void ClearPreviousMaterials() + { foreach (var m in s_PrevMaskMaterials) StencilMaterial.Remove(m); + s_PrevMaskMaterials.Clear(); foreach (var m in s_PrevModifiedMaterials) ModifiedMaterial.Remove(m); + s_PrevModifiedMaterials.Clear(); } private Material GetModifiedMaterial(Material baseMaterial, Texture2D texture)