detect click on collider like button


that one detects click. but what i want to do is making OnMouseUp() like a button
the ui button doesnt work if user drag out of its place.

how can i make OnMouse~~() possible to cancle like ui button?
will be much better without using raycast.

public void OnMouseUpAsButton()

this does what i ment