Problems with raycasting

Hello,
Today I have been trying some raycasting for roguelike games.
Things that are out of sight should be disabled. It all works except for the walls.
I can’t seem to find this problem.
http://puu.sh/kTHUQ/5c87c3da49.png

using UnityEngine;
using System.Collections;

public class LineOfSightRendering : MonoBehaviour
{
    private string viewerTag = "Player";
    public LayerMask layerMask = -1;
    private GameObject player;
   
    void Update ()
    {
        if(player == null)
        {
            player = GameObject.FindGameObjectWithTag(viewerTag);
        }

        //debug drawline
        if(this.tag == "BreakableWall")
        {
            Debug.DrawLine(player.transform.position, transform.position, Color.blue);
        }
           
        RaycastHit2D hit;
        hit = Physics2D.Raycast(new Vector2(transform.position.x,transform.position.y), player.transform.position - transform.position, 10, layerMask);
        if (hit)
        {
           
            if (hit.collider.gameObject == player)
            {
                GetComponent<Renderer>().enabled = true;
            }
            else
            {
                GetComponent<Renderer>().enabled = false;
            }
        }
        else
        {
            GetComponent<Renderer>().enabled = false;
        }
   
    }
}

I found that the problem is with the 2DBoxColliders.
Anyone has a sollution?