1. 程式人生 > >設定 unity shader 半透明

設定 unity shader 半透明

/// <summary>
/// 設定材質球半透明
/// </summary>
/// <param name="material"></param>
void SetMaterialTransparent(Material[] material)
{
     for (int i = 0; i < material.Length; i++)
     {
           Color color = material[i].color;
          //color.a = Mathf.Lerp(0f, 1f, t);
           color.a = 0.1f;
           material[i].color = color;
           material[i].SetFloat("_Mode", 2f);
           material[i].SetInt("_SrcBlend", 5);
           material[i].SetInt("_DstBlend", 10);
           material[i].EnableKeyword("_ALPHABLEND_ON");
           material[i].renderQueue = 3000;
     }
}