Input.GetMouseButtonDown only works for 10seconds

Hi all, I have a simple script to select a gameobject to be the selected unit.
However, after 10 seconds or so - Input.GetMosueButtonDown doesnt work anymore.

I have put this method in Update(). Does anyknow what the problem can be? It works for 10 seconds and then it stops working.

public void RangedAttack()
{
    if(Input.GetMouseButtonDown(1))
    {
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if(Physics.Raycast(ray, out hit))
        {
            if(hit.transform.tag == "Enemy")
            {
                selectedUnit = hit.transform.gameObject;
                Debug.Log(hit);
            }
        }
    }
}

you can try to create a bool when you press the button, oplhe try like this:

public void RangedAttack()
{
    if(Input.GetMouseButtonDown(1))
    {
        pressing = true;
    }
    else if(Input.GetMouseButtonUp(1))
    {
        pressing = false;    
    }
    if(pressing == true)
    {
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;
        if(Physics.Raycast(ray, out hit))
        {
             if(hit.transform.tag == "Enemy")
             {
                 selectedUnit = hit.transform.gameObject;
                 Debug.Log(hit);
             }
         }
     }
}

Nevermind… For some reason - it is fixed now? A day later with no real change, it works. Not sure what the problem was.