Unity tells me that “o.color” is not a struct or array, but it is clearly defined as one.
Shader "Custom/VertexColorsOnly" {
SubShader {
Pass {
CGPROGRAM
#pragma vertex vert
#include "UnityCG.cginc"
struct v2f {
float4 color : COLOR;
};
v2f vert( appdata_base v )
{
v2f o;
o.color = v.color;
return o;
}
ENDCG
}
}
}
color is not included in appdata_base,you need to declare your own.I have done it here:
Shader "Custom/VertexColorsOnly" {
SubShader {
Pass {
CGPROGRAM
#pragma vertex vert
#include "UnityCG.cginc"
struct appdata {
float4 color;
float4 vertex;
};
struct v2f {
float4 pos :POSITION;
float4 color : COLOR;
};
v2f vert( appdata v )
{
v2f o;
o.pos = mul( glstate.matrix.mvp, v.vertex );
o.color = v.color;
return o;
}
ENDCG
}
}
}