I’m trying to use a shader with 2 textures in properties. The first texture is “_MainTex”, the second is “_HoleTex”. I get the error “Material doesn’t have a texture property ‘_HoleText’” after calling GetTexture(“_HoleText”). I’m clueless, thank you for any help.
On my C# code, to test the shader, I’m calling :
material.SetTexture("_HoleText",_holeTexture); //_holeTexture is not null
Texture textureTest=material.GetTexture("_HoleText"); //textureTest is null
And here is the shader code.
Shader "Futile/Hole0"
{
Properties
{
_HoleTex ("Hole (RGB) Trans (A)", 2D) = "white" {}
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Color ("Main Color", Color) = (1,1,1,1)
}
Category
{
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Opaque"}
ZWrite Off
//Alphatest Greater 0
Blend SrcAlpha OneMinusSrcAlpha
Fog { Color(0,0,0,0) }
Lighting Off
Cull Off //we can turn backface culling off because we know nothing will be facing backwards
BindChannels
{
Bind "Vertex", vertex
Bind "texcoord", texcoord
Bind "Color", color
}
SubShader
{
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#pragma profileoption NumTemps=64
float4 _Color;
sampler2D _MainTex;
sampler2D _HoleTex;
struct v2f {
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
};
float4 _MainTex_ST;
v2f vert (appdata_base v)
{
v2f o;
o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
o.uv = TRANSFORM_TEX (v.texcoord, _MainTex);
return o;
}
half4 frag (v2f i) : COLOR
{
half4 texcol = tex2D (_MainTex, i.uv) * _Color;
texcol.a *= tex2D(_HoleTex, i.uv).a ;
return texcol;
}
ENDCG
}
}
}
}