The question is answered, right answer was accepted
How to click button multiple times
Hi Guys, Could you please help me to understand how I can click on button multiple times and invoke the same event.
Case example: I want to click on the same button and add the score. The current case gives me to click only once.
//Method logic
public void AddBet(int coinBetCount)
{
int availableMoney = PlayerMoney;
if (availableMoney == 0)
{
//TODO: Show dialog you don't have enought money to bet
Debug.Log("you don't have enought money to bet");
}
if (availableMoney >= coinBetCount)
{
_playerTotalBet += coinBetCount;
Debug.Log("Bet was set " + coinBetCount);
}
else
{
//TODO: Show dialog you don't have enought money to bet
Debug.Log("you don't have enought money to bet");
}
}
//Invoke AddBet
public void AddBet()
{
_gameProcessObject.AddBet(BetCount);
}
//Add this method on Click:
Debug message shows a message with the score only once. Maybe It's easier to do via script. Thanks.
Add a collider to the object and add this to the script
public void On$$anonymous$$ouseDown()
{
_gameProcessObject.AddBet(BetCount);
}
and remove the OnClick() event listener
1) Added 2DCircleCollider 2) Add method you've mentioned. 3) Used this method on Click. 4) I didn't have listeners.
A button is not clickable at all. Could you please explain more clearly. Looks like I missed something.
Your code is fine. Except if you see an error message(make sure your console shows error messages)
$$anonymous$$ake sure the click is detected by adding a Debug.Log
outside the conditions.
$$anonymous$$ake sure nothing blocks the raycast after the first click (an other UI element, ...)
I've added Debug.Log outside. It shows the message only after the first click. So, it's a click problem. I removed RayCastTarget checkbox at all. Nothing blocks this button. But it's a child for the empty object.