Skip to content

Commit

Permalink
feat: compatibility with other IMaterialModifier
Browse files Browse the repository at this point in the history
Close #115
  • Loading branch information
mob-sakai committed Nov 15, 2020
1 parent 06d8fae commit 08273cb
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Scripts/UIParticle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class UIParticle : MaskableGraphic
private static MaterialPropertyBlock s_Mpb;
private static readonly List<Material> s_PrevMaskMaterials = new List<Material>();
private static readonly List<Material> s_PrevModifiedMaterials = new List<Material>();
private static readonly List<Component> s_Components = new List<Component>();


/// <summary>
Expand Down Expand Up @@ -124,6 +125,11 @@ public IEnumerable<Material> materials
get { return _modifiedMaterials; }
}

public override Material materialForRendering
{
get { return canvasRenderer.GetMaterial(0); }
}

public List<bool> activeMeshIndices
{
get { return _activeMeshIndices; }
Expand Down Expand Up @@ -250,6 +256,7 @@ protected override void UpdateMaterial()
}

//
GetComponents(typeof(IMaterialModifier), s_Components);
var materialCount = Mathf.Max(8, count);
canvasRenderer.materialCount = materialCount;
var j = 0;
Expand All @@ -268,6 +275,8 @@ protected override void UpdateMaterial()
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++;
Expand All @@ -279,6 +288,8 @@ protected override void UpdateMaterial()
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++);
}
}
Expand Down

0 comments on commit 08273cb

Please sign in to comment.