Hi everone,
I have some problems when changing alpha percent of the materials.
I got this strange view when i change the alpha value of its material like below.
public static void SetTransparentOfObject(GameObject obj, float TransparentPercent)
{
foreach (Material m in obj.GetComponent<Renderer>().materials)
{
m.SetFloat("_Mode", 2);
m.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
m.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
m.DisableKeyword("_ALPHATEST_ON");
m.EnableKeyword("_ALPHABLEND_ON");
m.renderQueue = 3000;
m.color = new Color(m.color.r, m.color.g, m.color.b, TransparentPercent);
}
}
I wrote this code to do that. Can you tell me where is my wrong, thanks.