Set alpha in Standard Shader

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.

void SetAlpha(float value)
Color color = yourgameobject.GetComponent().materials[0].color;
color.a = value;
yourgameobject.GetComponent().materials[0].color = color;

Hi to change the alpha most of time its the alpha of the main texture that you need to change…

Material mat = new Material(_meshRenderer.sharedMaterial);
Color col = mat.mainTexture.color;
col.a = alpha;
mat.mainTexture.color = col;

Hope this help…