Hello!
I have tried implementing the solution as follows:
public void Awake()
{
skel.OnMeshAndMaterialsUpdated += UpdateMats;
}
private void UpdateMats(SkeletonRenderer skeletonRenderer)
{
meshRenderer.materials.Add(meterialIWantToUse);
}
The code did run as I expected. However, the second material just replaces the previous one, the same as if I was using the included material override tools.
The behavior we want to reproduce is to have both run at the same time, as if the mesh renderer had two materials running simultaneously, instead of swapping them around.
We want to be able to achieve this:
Either through code or editor.
EDIT: Hello again! We managed to solve things around. I forgot you can't directly set the materials. The following code works as expected:
public void Awake()
{
skel.OnMeshAndMaterialsUpdated += UpdateMats;
UnityEngine.Material[] sharedMaterial = meshRenderer.sharedMaterials;
vMats = new UnityEngine.Material[sharedMaterial.Count() + 1];
vMats[0] = materialToReplace;
vMats[1] = materialIWantToUse;
}
private void UpdateMats(SkeletonRenderer skeletonRenderer)
{
meshRenderer.materials = vMats;
}