Reputation: 5497
I'm using Unity UI introduced in 4.6, and the button works fine. However, I have the game underneath controlled by touch. If the user touches the left of the screen, hero turns left, if the right side, it turns right. But if the user touches a button, it still turns right.
if (Input.touches[0].position.x < Screen.width / 2) {
turnLeft();
} else {
turnRight();
}
how can I make this code unresponsive if the touch/mouse clicked the ui button?
Upvotes: 0
Views: 1541
Reputation: 5497
if (!EventSystem.current.IsPointerOverGameObject()) {
//same code here
}
Upvotes: 1