How can I push material at the end of meshRender Array?
Here is my code
[SerializeField] private MeshRenderer meshRenderer;
public void PushMaterial (Material newMaterial)
{
if (!meshRenderer) return;
meshRenderer.materials [meshRenderer.materials.Length - 1] = newMaterial;
}
NOTE!
I'm sure the newMaterial
reference is not null and also meshRenderer.material = newMaterial
is working but I want to push it at the end of the Array.
CodePudding user response:
Like this:
Duplicate from Unity Forms