feat: compatibility with other IMaterialModifier

Close #115
pull/120/head
mob-sakai 2020-11-16 03:07:24 +09:00
parent 06d8fae58f
commit 08273cb0c3
1 changed files with 11 additions and 0 deletions

View File

@ -57,6 +57,7 @@ namespace Coffee.UIExtensions
private static MaterialPropertyBlock s_Mpb; private static MaterialPropertyBlock s_Mpb;
private static readonly List<Material> s_PrevMaskMaterials = new List<Material>(); private static readonly List<Material> s_PrevMaskMaterials = new List<Material>();
private static readonly List<Material> s_PrevModifiedMaterials = new List<Material>(); private static readonly List<Material> s_PrevModifiedMaterials = new List<Material>();
private static readonly List<Component> s_Components = new List<Component>();
/// <summary> /// <summary>
@ -124,6 +125,11 @@ namespace Coffee.UIExtensions
get { return _modifiedMaterials; } get { return _modifiedMaterials; }
} }
public override Material materialForRendering
{
get { return canvasRenderer.GetMaterial(0); }
}
public List<bool> activeMeshIndices public List<bool> activeMeshIndices
{ {
get { return _activeMeshIndices; } get { return _activeMeshIndices; }
@ -250,6 +256,7 @@ namespace Coffee.UIExtensions
} }
// //
GetComponents(typeof(IMaterialModifier), s_Components);
var materialCount = Mathf.Max(8, count); var materialCount = Mathf.Max(8, count);
canvasRenderer.materialCount = materialCount; canvasRenderer.materialCount = materialCount;
var j = 0; var j = 0;
@ -268,6 +275,8 @@ namespace Coffee.UIExtensions
if (activeMeshIndices[index] && 0 < s_TempMaterials.Count) if (activeMeshIndices[index] && 0 < s_TempMaterials.Count)
{ {
var mat = GetModifiedMaterial(s_TempMaterials[0], ps.GetTextureForSprite()); 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); canvasRenderer.SetMaterial(mat, j);
UpdateMaterialProperties(r, j); UpdateMaterialProperties(r, j);
j++; j++;
@ -279,6 +288,8 @@ namespace Coffee.UIExtensions
if (activeMeshIndices[index] && 1 < s_TempMaterials.Count) if (activeMeshIndices[index] && 1 < s_TempMaterials.Count)
{ {
var mat = GetModifiedMaterial(s_TempMaterials[1], null); 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++); canvasRenderer.SetMaterial(mat, j++);
} }
} }