Screen moves on clicking the button

I am using following code to throw the ball. When the player clicks on “Hit” button the screen also moves to the left side.

I need solutions for two different situations if any can help:

  1. Either the screen does not move on clicking the GUI Button.
  2. Either I remove the button and click to fire using:
    if(Input.GetButtonDown(“Fire1”)) instead of Gui.Button
    in this case also when the screen is touched to “Fire” or even “move the screen” to the left or right, the ball is thrown and the screen also moves to the left/right side.


Zia Khatri

function OnGUI() {
if(GUI.Button(Rect(125, Screen.height-125 , 250, 125), “Hit”) ) {
if(actionStatus == false){
var ball: GameObject = Instantiate(ballPrefab, transform.position, Quaternion.identity) as GameObject;
ball.rigidbody.AddForce(transform.forward * 900);
actionStatus = true;

Yes, I mean the camera moves on Gui Button click.