From 425aad0cbab475635c72bee84ecbf3f2acedccc2 Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Mon, 14 Aug 2023 15:47:07 +0900 Subject: [PATCH] fix: nullReferenceException after copy-n-paste close #258 --- Scripts/UIParticleRenderer.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Scripts/UIParticleRenderer.cs b/Scripts/UIParticleRenderer.cs index f1e7c6e..5f4d1f0 100644 --- a/Scripts/UIParticleRenderer.cs +++ b/Scripts/UIParticleRenderer.cs @@ -112,7 +112,12 @@ namespace Coffee.UIExtensions { _currentMaterialForRendering = null; - if (!IsActive()) return baseMaterial; + if (!IsActive() || !_parent) + { + ModifiedMaterial.Remove(_modifiedMaterial); + _modifiedMaterial = null; + return baseMaterial; + } var modifiedMaterial = base.GetModifiedMaterial(baseMaterial); @@ -157,6 +162,12 @@ namespace Coffee.UIExtensions _lastBounds = new Bounds(); enabled = false; } + else + { + ModifiedMaterial.Remove(_modifiedMaterial); + _modifiedMaterial = null; + _currentMaterialForRendering = null; + } } public void Set(UIParticle parent, ParticleSystem particleSystem, bool isTrail)