GameObject as toggle button with touch

I’m trying to make a gameobject as a toggle button which works with touch. here’s my code which works but there’s a problem. if you don’t release your finger from screen the toggle button keeps toggling . I’m looking for something like “OnMouseRelease” function.

function FixedUpdate()
{
 if(Input.touchCount>0)
 {
  var theTouch : Touch = Input.GetTouch(0);
  var ray = Camera.main.ScreenPointToRay(theTouch.position);
  if(Physics.Raycast(ray,hit,500000,layerMask))
  {
   if(Input.touchCount==1)
   {
    var hitTag = hit.transform.tag;
    if(hit.transform.CompareTag("toggleBtn")
    {
     //do actions
    }
   }
  }
 }
}

I tried to embrace it with a condition of TouchPhase.Began but it didn’t work either . I also tried to add a boolean as a condition and make it active by a delay with yield but it didn’t work either.

TouchPhase.Began should work. Could you test it in Update instead of FixedUpdate?

And please take a look at this question.