Hi,
I just tried to use the new “MaterialPropertyDrawer” features of the 4.3 release to write a shader that would have enabled/disabled options but while i succeeded in using the enum i could not have the checkbox to work as expected.
Here is a simple shader i wrote to test this feature, it is supposed to change the color based on the value of the _Invert Property.
If someone can point out what i may have done wrong here, that would be great.
Thanks in advance !
Shader "Basic"
{
Properties
{
_Color1 ("Color 1", color) = (1,1,1,1)
_Color2 ("Color 2", color) = (0,0,0,1)
[Toggle] _Invert ("Invert Color ?", Float) = 0
}
SubShader
{
Tags { "Queue"="Geometry" }
Cull Off
Lighting Off
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile _INVERT_ON _INVERT_OFF
#include "UnityCG.cginc"
uniform fixed4 _Color1;
uniform fixed4 _Color2;
struct vertexInput
{
float4 vertex : POSITION;
half2 texcoord : TEXCOORD0;
};
struct vertexOutput
{
float4 pos : SV_POSITION;
half2 tex : TEXCOORD0;
};
vertexOutput vert(vertexInput input)
{
vertexOutput output;
output.tex = input.texcoord;
output.pos = mul(UNITY_MATRIX_MVP, input.vertex);
return output;
}
fixed4 frag(vertexOutput input) : COLOR
{
fixed4 color = fixed4(1.0,0.0,0.0,1.0);
#if _INVERT_ON
color = _Color1;
#else
color = _Color2;
#endif
return color;
}
ENDCG
}
}
CustomEditor "CustomMaterialInspector"
}