• Unity
  • how to change transparency in script

Hi,
I use code like this to change the transparency for animation:

    fillColor = Shader.PropertyToID("_FillColor");
    mpb.SetColor(fillColor, new UnityEngine.Color(1, 1, 1, 0));
    meshRenderer.SetPropertyBlock(mpb);

I can find the alpha has been set to 0 in inspector panel, but the object still can be seen.
Is anyone know how to make it?
Thanks.

Related Discussions
...
  • Изменено

The color material property that tints the texture and is able to make it render transparent is usually named "Color".
Use that instead of "
FillColor".

This can also be different depending on the shader you are using. If "_Color" does not work, make sure you check the material properties list on your shader for the correct property name.