Get pixel colour on a ray hit

I’m trying to get the pixel colour where the ray hits the texture, it’s a simple black and white maze map.

I know I’m doing something wrong here, but if somebody could help I’d really appreciate it. Here’s the code:

if (Physics.Raycast (ray, hit)) {
	var TextureMap: Texture2D = hit.transform.renderer.material.mainTexture;
	var pixelUV = hit.textureCoord;
    	pixelUV.x *= TextureMap.width;
    	pixelUV.y *= TextureMap.height;

        print ( "x=" + pixelUV.x + ",y=" + pixelUV.y + " " + TextureMap.GetPixel (pixelUV.x,pixelUV.y) );


}

X and Y are both coming out as zero. the texture is RGB Compressed DXT1 - does it need to be something else ?

What kind of collider is the Texture on? hit.textureCoord only works on MeshColliders (as documented in the scripting reference). Other then that, I see nothing wrong with the code.