- Home /
Question by
sayginkarahan · May 06, 2018 at 07:57 PM ·
materialtransparencyalphadots
Black dots when changed the alpha of the material
Hi everone,
I have some problems when changing alpha percent of the materials. I got this strange view.
How I can remove these black dots on the object.
I change the alpha with these codes 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);
}
}
Thank you.
dots.png
(163.0 kB)
Comment