How to prevent character from jumping, when clicking pause-button

Hey there,

I got a little issue again: I created a Pause-Button which stops the game through changing the Time.timescale, but by clicking the button, my character jumps (jumping is forced by Input.GetButtonDown (“Fire1”)), and when clicking the resume-button the game, he does his doublejump. So for that reason, I need to somehow “deactivate” the Input of the active game while hovering over or by clicking the button. The game is supposed to run on mobile phones also, so it needs to know that over the buttons, the player controls are deactivated…I found some suggestions but none of them really work for me somehow :frowning: (like for example: http://forum.unity3d.com/threads/4-6-how-to-detect-if-any-gui-element-has-been-clicked-on.263473/)

Thanks in advance

best regards

The way dealt with mouse over ui, i have an array, that contains my UI elements that i do not want to let the click go through;
I assigned the UI elements in the inspector.

//Holds all ui elements that don't let the touches/clicks pass through to the scene
public RectTransform[] uiElements;

/**
 * Tests if the mouse button is over UI
 */
public bool isMouseOverUI() {
    Vector2 mousePosition = Input.mousePosition;
	foreach (RectTransform elem in uiElements) {
		if (!elem.gameObject.activeSelf) {
			continue;
		}
		Vector3[] worldCorners = new Vector3[4];
		elem.GetWorldCorners(worldCorners);

		if(mousePosition.x >= worldCorners[0].x && mousePosition.x < worldCorners[2].x 
		   && mousePosition.y >= worldCorners[0].y && mousePosition.y < worldCorners[2].y) {
			return true;
		}
	}	
	return false;
}

When jumping, just test first for isMouseOverUI();

Alternatively you can play around with

EventSystem.current.IsPointerOverGameObject()

http://docs.unity3d.com/ScriptReference/EventSystems.EventSystem.IsPointerOverGameObject.html
But i found that it did not work correctly with touches (on android device). This was in 4.6 beta, haven’t tried to use it again yet, maybe it was fixed.