I want to set the alpha of a material with the Standard Shader.
I created the following method.
public void SetAlpha(float alpha) {
Material mat = new Material(_meshRenderer.sharedMaterial);
mat.color = new Color(mat.color.r, mat.color.g, mat.color.b, alpha);
_meshRenderer.sharedMaterial = mat;
}
However after using the method the new alpha value is not displayed. When I inspect the Material the new alpha value is shown. Only if I modify the alpha value by hand does the value get updated.
**EDIT** I already made sure that the render mode is set to transparent in the base material.
↧