Is there a way to do different things depending on whether the button is being held or tapped?

For example I want to do a light attack when the “attack” button is tapped and do a heavy attack when the button is being held down. I tried using Input.GetButtonDown for light attack and Input.GetButton for heavy attack, but that doesn’t work.

if (Input.GetButtonDown("attack")) 
		{
			attackState = 1;
		}
		else if (Input.GetButton("attack")) 
		{
			attackState = 2;
		}

Add a boolean and a timer, specifying when to consider your attack being “Heavy”.

var buttonDown: boolean;
var buttonDownTimer: float;
var heavyAttackThreshold: float;

function Update()
{
       if (Input.GetButtonDown("attack")) 
      {
              buttonDown = true;
       }
       if(buttonDown)
       {
              buttonDownTimer += Time.deltaTime;
       }
       if (Input.GetButtonUp("attack")) 
       {
              buttonDown = false;
              if(buttonTimer >= heavyAttackThreshold)
              {
                     attackState = 2;
              }
              else
              {
                     attackState = 1;
              }
       }
}

By Script

OnMouseOver()
OnMouseEnter()
OnMouseDown()
OnMouseUp()
OnMouseDrag()