I m trying to Make laser with Raycast2D but collision of raycast is not getting detect. How can i get it fixed?

using UnityEngine;
using System.Collections;
using UnityEditor;

[RequireComponent(typeof(LineRenderer))]


public class LaserEffect : MonoBehaviour {
	RaycastHit2D hit;
	Ray2D ray;
	private	LineRenderer line;
	

	// Use this for initialization
	void Start () {
		line = GetComponent<LineRenderer>();
	   
		
	}

	// Update is called once per frame
	void Update () 
	{


		if (hit.collider.attachedRigidbody) 
			{

				if (hit.collider.tag == "blue" || hit.collider.tag == "purple" || hit.collider.tag == "green" || hit.collider.tag == "pink" || hit.collider.tag == "yellow")
				{
					Debug.Log (hit.collider.tag);
				}

			}
		}


	}

You never cast a ray from what I can tell you need to cast a ray and check the hit variable

private float InteractionRange = 5.0f;


RaycastHit hit;
        Ray Vision_Ray = new Ray(Cam.transform.position, Cam.transform.forward * InteractionRange);  // I used camera you can use whatever you need.
        if (Physics.Raycast(Vision_Ray, out hit, InteractionRange))
        {
           switch(hit.collider.tag)
           {
               case "red":
               case "pink":
               case "blue":  // just add in all the cases
                   Debug.Log("Hit " + hit.collider.tag);
                   break;
               case "wall":
                   Debug.Log("Hit a wall");
                   break;
                case default:
                   Debug.Log("Hit an undefined object.");
                   break;
           }
        }