I'm trying to find the name of the tile which is being hit on. But for the debug.log() line of the code, it keeps saying
NullReferenceException: Object reference not set to an instance of an object
Below is my code:
    if (Input.GetMouseButtonDown(0)) 
    {
        Ray ray = _camera.ScreenPointToRay(Input.mousePosition);
        RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction);
        Debug.Log(hit.transform.name);
     
    }
 
    