NGUI按钮至灰代码
this.GetComponent<UIButton> ().isEnabled = false;
修改NGUI shader
struct v2f
{
float4 vertex : SV_POSITION;
half2 texcoord : TEXCOORD0;
fixed4 color : COLOR;
fixed gray : TEXCOORD1;
};
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert (appdata_t v)
{
v2f o;
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
o.color = v.color;
o.gray = dot(v.color, fixed4(1,1,1,0));
return o;
}
fixed4 frag (v2f i) : COLOR
{
fixed4 col;
if (i.gray == 0)
{
col = tex2D(_MainTex, i.texcoord);
col.rgb = dot(col.rgb, fixed3(.222,.707,.071));
col.a = i.color.a;
}
else
{
col = tex2D(_MainTex, i.texcoord) * i.color;
}
return col;
}
参考 http://blog.csdn.net/asd237241291/article/details/23951305#comments
修改按钮编辑视图中的disable状态的颜色
R,G,B=0;(这一步很重要);