How to add Metallic texture functionality to surface shader?

Hi I currently have a custom surface shader that has a special effect on top of duplicating most of the other functionality from the standard shader. However, I can’t figure out how to add functionality to support Metallic textures like in the standard shader.

struct SurfaceOutputStandard
{
    fixed3 Albedo;      // base (diffuse or specular) color
    fixed3 Normal;      // tangent space normal, if written
    half3 Emission;
    half Metallic;      // 0=non-metal, 1=metal
    half Smoothness;    // 0=rough, 1=smooth
    half Occlusion;     // occlusion (default 1)
    fixed Alpha;        // alpha for transparencies
};

From the docs, this is the struct that is output. However, Metallic is just a half data type. How do i use a texture to define the Metallic-ness like in the standard shader?

You define it as you would any other texture, however you only use one colour channel. From memory, the metallic texture in the default Standard shader uses alpha for specularity and the r channel for metallic, so it would look something along the lines of;

o.Metallic = tex2D (_SpecMap, IN.uv_SpecMap).r;