- Home /
Weird GUI problem
Hi. In my OnGUI funciton i am using a GUI.Button to move my character but i dont have to click on it and its mocing by himself... and also " Move " is written on the console every frame.I have been using this OnGUI function in other games and was working fine , i dont know what happend to unity but it is not working poperly.THANKS FOR THE HELP!
#pragma strict
public var skin : GUISkin;
public var player1 : GameObject;
function OnGUI()
{
GUI.skin = skin;
if ( GUI.Button ( Rect ( 0 , 0 , 100 , 100 ) , " " ) ) ;
{
player1.rigidbody2D.velocity = Vector2 ( 0 , 10 );
Debug.Log( " Move " ) ;
}
}
Answer by tanoshimi · Jun 08, 2014 at 06:52 PM
Nothing happened to Unity. What happened is that you mistakenly put a semicolon at the end of this line:
if ( GUI.Button ( Rect ( 0 , 0 , 100 , 100 ) , " " ) ) ;
Try getting rid of it and you find your if() statement works as you expect.
Your answer
Follow this Question
Related Questions
Build completed with a result of failed (can't build my android game) 2 Answers
GUI Texture error. 1 Answer
C# Script issue with Player 1 Answer
What exactly this error is trying to inform me about? 1 Answer
Item Scripting Error 2 Answers