I am using this method to convert opaque rendering mode to transparent.

item.color = new Color(1, 1, 1, value);
item.SetOverrideTag("RenderType", "Transparent");
item.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
item.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
item.SetInt("_ZWrite", 0);
item.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent;

This is working fine but not working in my webgl build.

  • 1
    \$\begingroup\$ Can you confirm whether you have any materials used in your project that have that set of keywords enabled out-of-the-box? If not, then Unity might not have compiled a matching variant when exporting your game, so when you try to change the keywords at runtime, Unity finds to matching shader variant and can't honour the request. See this answer for more details \$\endgroup\$
    – DMGregory
    Sep 29, 2020 at 17:03
  • \$\begingroup\$ Yes, you are right, I am not using the variant in my project. For a workaround, I just added the standard shader in graphic settings and it is working. But it has significantly increase my build size. Previously it was 65 mb now its around 100 mb. Any efficient way to deal this \$\endgroup\$ Sep 30, 2020 at 6:38
  • \$\begingroup\$ Yea: create just one material with the one shader variant you need, and reference it somewhere. \$\endgroup\$
    – DMGregory
    Sep 30, 2020 at 9:22


You must log in to answer this question.

Browse other questions tagged .