Muhammad
Muhammad

Reputation: 1

When hold pressed ui canvas button on mouse down do something when released do something

public void application()    // function when the mouse only find the ui canvas button 
{
    // when the mouse find only canvas button and when clicked then do something else stop

    if (Input.GetButton("Fire1"))
    {
        print("button pressed");
    }
    else {
        print("button released");
    }
}

Upvotes: 0

Views: 200

Answers (1)

Everts
Everts

Reputation: 10701

When dealing with the UI system, you should use the IPointerXXXX interfaces:

public class MyClass: MonoBehaviour, IPointerUpHandler{

    public void OnPointerUp(PointerEventData eventData)
    {
        throw new NotImplementedException();
    }
}

Upvotes: 1

Related Questions