How do i add an image to only the +Z side of a square game object in Unity?

24 Views Asked by At

I've been looking for a little while, and I can't find anything that helps with this.

I tried using a custom shader,

Shader "Custom/ZSideShader"
{
    Properties
    {
        _MainTex ("Base (RGB)", 2D) = "white" { }
    }

    SubShader
    {
        Tags { "Queue" = "Overlay" }

        CGPROGRAM
        #pragma surface surf Lambert

        struct Input
        {
            float2 uv_MainTex;
        };

        sampler2D _MainTex;

        void surf(Input IN, inout SurfaceOutput o)
        {
            fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
            o.Albedo = c.rgb;
            o.Alpha = c.a;
        }
        ENDCG
    }

    SubShader
    {
        Tags { "Queue" = "Overlay" }

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma exclude_renderers gles xbox360 ps3 ps4 xboxone
            ENDCG

            SetTexture[_MainTex]
            ColorMask RGB
            ZWrite On
            ZTest GEqual
        }
    }
}

, and applying it to a materials shader and putting the material on the cube, but it says that it cant compile

0

There are 0 best solutions below