From 08273cb0c340ccb4f35120dc804c37d758da9ce1 Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Mon, 16 Nov 2020 03:07:24 +0900 Subject: [PATCH] feat: compatibility with other IMaterialModifier Close #115 --- Scripts/UIParticle.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Scripts/UIParticle.cs b/Scripts/UIParticle.cs index c3c814e..1e10b0d 100755 --- a/Scripts/UIParticle.cs +++ b/Scripts/UIParticle.cs @@ -57,6 +57,7 @@ namespace Coffee.UIExtensions private static MaterialPropertyBlock s_Mpb; private static readonly List s_PrevMaskMaterials = new List(); private static readonly List s_PrevModifiedMaterials = new List(); + private static readonly List s_Components = new List(); /// @@ -124,6 +125,11 @@ namespace Coffee.UIExtensions get { return _modifiedMaterials; } } + public override Material materialForRendering + { + get { return canvasRenderer.GetMaterial(0); } + } + public List activeMeshIndices { get { return _activeMeshIndices; } @@ -250,6 +256,7 @@ namespace Coffee.UIExtensions } // + GetComponents(typeof(IMaterialModifier), s_Components); var materialCount = Mathf.Max(8, count); canvasRenderer.materialCount = materialCount; var j = 0; @@ -268,6 +275,8 @@ namespace Coffee.UIExtensions if (activeMeshIndices[index] && 0 < s_TempMaterials.Count) { var mat = GetModifiedMaterial(s_TempMaterials[0], ps.GetTextureForSprite()); + for (var k = 1; k < s_Components.Count; k++) + mat = (s_Components[k] as IMaterialModifier).GetModifiedMaterial(mat); canvasRenderer.SetMaterial(mat, j); UpdateMaterialProperties(r, j); j++; @@ -279,6 +288,8 @@ namespace Coffee.UIExtensions if (activeMeshIndices[index] && 1 < s_TempMaterials.Count) { var mat = GetModifiedMaterial(s_TempMaterials[1], null); + for (var k = 1; k < s_Components.Count; k++) + mat = (s_Components[k] as IMaterialModifier).GetModifiedMaterial(mat); canvasRenderer.SetMaterial(mat, j++); } }