I am working on a game for android. If you touch anywhere on the screen the player moves up and if you release the screen the player goes down. I wanted to add a button that if you pressed it the player would shoot a projectile. I ran into the problem of when you are clicking the button the player still moves up. I figured that I would increase the points of contact required to move the player up if the button is being pressed. I am going to make the button call a method in another script on the player. Right now the method on the player script just runs Debug.Log(). I have it up and running but the problem is the method I have set to run OnClick only runs one time. I click the button over and over and it never runs a second time. I am testing this in the unity game editor not on android but I have my scripts running in the Desktop configuration so that should not be causing a problem.
Lot of guys in the forums, having issues, with OnClick ( ) which doesn’t able to identify Game Objects accrdingly, For specific click on game objects and to identify which object is clicked and what is not necessarily done through onClick( ).
try using :
void OnMouseDown( )
{
//Code
}
I had the exact same problem and you are going to hate yourself for this.
The Debug.Log entry on the Console stacks multiple entries with the same message. A small number on the right indicates the number of times the same log entry has occurred, which I didn’t notice initially as well.