I need help to make a Ray hit a 2D sprite hexagon map.

I also need to be able to select and detect 3D models aswell as the sprites, is it possible for me to do both?

Thanks guys.

// Use this for initialization
void Start()
{

}

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

   

   
    Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

    RaycastHit hitInfo;
    if (Physics.Raycast(ray, out hitInfo))
    {
        RaycastHit2D hit = Physics2D.GetRayIntersection(ray, Mathf.Infinity);
        if (hit.collider != null)
        {

            Debug.Log("Uncle Ray Ray hit someone ");

        }

    

    }
}

}

Try with Physics.RaycastAll function. Both 2D (Sprites) and 3D objects should have 3D colliders on them. Put a 3D collider on an empty child game object and resize the collider to size appropriate to your sprite. Physics2D.RaycastAll will hit only 2D colliders, and Physics.RaycastAll only 3D colliders.

Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit[] hitInfo = Physics.RaycastAll(ray.origin, ray.direction);
foreach (RaycastHit h in hitInfo)
{
    if (h.collider.name == "UncleRayTarget")
    {
        //do something
    }
}

I am not able to test this right now, but it should do the trick.