Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
This question was closed Apr 02, 2018 at 01:38 PM by Dneprokos for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Dneprokos · Aug 11, 2017 at 06:53 AM · buttonscript.canvasclicking

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.

addbetiui.jpg (10.0 kB)
Comment
Add comment · Show 5
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ShadyProductions · Jul 28, 2017 at 08:43 AM 0
Share

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

avatar image Dneprokos ShadyProductions · Jul 28, 2017 at 09:22 AM 0
Share

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.

avatar image Hellium · Jul 28, 2017 at 08:45 AM 1
Share

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, ...)

avatar image Dneprokos Hellium · Jul 28, 2017 at 09:13 AM 0
Share

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.

avatar image Dneprokos · Aug 03, 2017 at 12:14 PM 0
Share

The problem was resolved. This code works well.

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

83 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Question regarding sending clicks to another UI canvas. 1 Answer

When you click the same image twice it see it says a match. Any thoughts on how to fix that? 0 Answers

Create Button via Script not working 1 Answer

SteamVR GetState() Grip 0 Answers

Cant call void function from another script 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges