unity material 怎么换rendering mode
2个回答
展开全部
public enum RenderingMode
{
Opaque,
Cutout,
Fade,
Transparent,
}
public static void SetMaterialRenderingMode (Material material, RenderingMode renderingMode)
{
switch (renderingMode) {
case RenderingMode.Opaque:
material.SetInt ("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt ("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
material.SetInt ("_ZWrite", 1);
material.DisableKeyword ("_ALPHATEST_ON");
material.DisableKeyword ("_ALPHABLEND_ON");
material.DisableKeyword ("_ALPHAPREMULTIPLY_ON");
material.renderQueue = -1;
break;
case RenderingMode.Cutout:
material.SetInt ("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt ("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
material.SetInt ("_ZWrite", 1);
material.EnableKeyword ("_ALPHATEST_ON");
material.DisableKeyword ("_ALPHABLEND_ON");
material.DisableKeyword ("_ALPHAPREMULTIPLY_ON");
material.renderQueue = 2450;
break;
case RenderingMode.Fade:
material.SetInt ("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
material.SetInt ("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
material.SetInt ("_ZWrite", 0);
material.DisableKeyword ("_ALPHATEST_ON");
material.EnableKeyword ("_ALPHABLEND_ON");
material.DisableKeyword ("_ALPHAPREMULTIPLY_ON");
material.renderQueue = 3000;
break;
case RenderingMode.Transparent:
material.SetInt ("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt ("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
material.SetInt ("_ZWrite", 0);
material.DisableKeyword ("_ALPHATEST_ON");
material.DisableKeyword ("_ALPHABLEND_ON");
material.EnableKeyword ("_ALPHAPREMULTIPLY_ON");
material.renderQueue = 3000;
break;
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询