码迷,mamicode.com
首页 > 其他好文 > 详细

[原]NGUI之按钮置灰

时间:2014-07-28 14:52:43      阅读:392      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   使用   art   div   ar   

传统按钮置灰,需要使用另外一张纹理。

本例通过修改shader和NGUI sprite的r值实现按钮置灰。优势:节省纹理,操作简单

将NGUI Unlit/Transparent Colored片段部分改成如下:
fixed4 frag (v2f i) : COLOR { fixed4 col
= tex2D(_MainTex, i.texcoord) * i.color; if(i.color.r < 0.0001) { float grey = dot(col.rgb, float3(0.299, 0.587, 0.114)); col.rgb = float3(grey, grey, grey); } return col; }
说明:其中(0.299,0.587,0.114)为灰度公式的参数

使用时仅需将sprite的颜色R值设置为0即可!

参考资料:NGUI之UIButton"禁用"状态时置灰

[原]NGUI之按钮置灰,布布扣,bubuko.com

[原]NGUI之按钮置灰

标签:style   blog   http   color   使用   art   div   ar   

原文地址:http://www.cnblogs.com/U-tansuo/p/NGUI_Button_disable.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!