// configure the 2DTK listener events
void OnEnable() {
item = GetComponent<tk2dUIItem>();
item.OnDown += downPressed;
item.OnRelease += released;
}
// remove the 2DTK listener events
void OnDisable() {
item.OnDown -= downPressed;
item.OnRelease -= released;
}
// initiate the drag sequence from a given position
void downPressed () {
isBeingDragged = true;
startTouch = Input.mousePosition; // save the start position as a reference
}
// key released... disable the check
void released() {
isBeingDragged = false;
}
public event System.Action OnDown;
item.OnDown += downPressed;
注册回调函数,当按下时就会回调!