- Home /
Material doesn't have a color property '_Color' UnityEditor.DockArea:OnGUI()
Hi All,
I am very new in unity and wanted to learn how to write custom shader. Hence, I started learning from here.
I wrote the same code mentioned in the tutorial but unfortunately it is giving me error:
Material doesn't have a color property '_Color' UnityEditor.DockArea:OnGUI()
Code:
Shader "Custom/NewShader" {
Properties {
_Color ("Color",Color) = (1,1,1,1)
}
SubShader {
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
uniform float4 _Color;
struct vertexInput {
float4 vertex : POSITION;
};
struct vertexOutput {
float4 pos : SV_POSITION;
};
vertexOutput vert(vertexInput i) {
vertexOutput o;
o.pos = mul(UNITY_MATRIX_MVP,v.vertex);
return o;
}
float4 frag(vertexOutput i) : COLOR
{
return _Color;
}
ENDCG
}
}
}
I searched unity forum but could not find anything related to it. It would be great any one help to figure out where is the problem. I am using unity 4.0 pro version.
Please mention any other tutorial series that teach shader writing.
Many Thanks in advance!
This one is pretty good also if you are ai$$anonymous$$g vertex/fragment shaders as opposed to surface shaders http://en.wikibooks.org/wiki/Cg_Program$$anonymous$$g/Unity
Answer by SarperS · May 03, 2013 at 11:42 AM
You've made a simple typo. In your vertex program you've tried to use v.vertex but you've declared vertexInput as i. So instead of writing v.vertex, you should type in i.vertex.
Please feel free to check my answer as the correct one so this entry closes as "solved"
Thanks a lot Sarper! Please mark this thread as "Solved".
You are welcome, but I can't, you have to check it as "solved" :)