Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
1 capture
14 Jun 22 - 14 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 /
avatar image
0
Question by jakewcurrie01 · Jan 15 at 04:42 PM · buttonbutton trigger eventsonclick

Upgrade Button 3 & 4 calling on the Upgrade 2 method

I am new to game development, currently working on a tower defence game.

I have encountered an issue where both Upgrade 1 & Upgrade 2 buttons are working as intended. However, after adding a 3rd and 4th Upgrade button, they call on the Upgrade2() method instead of the Upgrade3() and Upgrade4() methods respectably even after I changed their on click event. (Buttons 1 & 2 work fine, it's just 3 & 4 that call on upgrade 2's method)

I have tried everything to sort the issue but I cannot find a solution and I would appreciate some help if possible. (There is two images attached of Upgrade2() and Upgrade3() for examples to show they are the same except for their prefab)alt text

upgrade2.png (32.4 kB)
upgrade3.png (31.8 kB)
Comment
Add comment · Show 19
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 mf41z · Jan 15 at 05:02 PM 0
Share

Can you show me where you're setting the events for the buttons?

Show more comments
avatar image rh_galaxy · Jan 16 at 01:19 PM 0
Share

Can you show the turrentBlueprint in the inspector, as much of it as possible...

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Chimer0s · Jan 16 at 04:51 AM

If the code is the same except for the prefab and you're sure that the onClick event of the button is calling the correct method, then the problem would have to be with your prefab assignment. If you have public references to them in the inspector, double check that prefab2 isn't in the prefab3 and prefab4 slots.

Also, it's helpful with things like this to use the built in debug methods to help spot your issue. You could add something like Debug.Log("Upgrade 3 called"); to the top of your UpgradeTurret3() and see if that comes up in the console when the button is clicked. Similarly you could add such a line to each of the upgrade methods to see which is being called when you click, just to confirm everything is working as it should. If those are called correctly, it's an issue with the prefabs, if they aren't and the inspector says you have the right methods selected for your buttons, it might just be that Unity needs a restart.

Comment
Add comment · Show 1 · Share
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 jakewcurrie01 · Jan 16 at 10:18 AM 0
Share

Hi, thanks for your answer. I did actually implement a debug.log statement into the Upgrade methods and whenever I pressed the 3rd or 4th button it would put "Upgrade 2" in the console. Thats why I was so confused whilst investigating it as I couldn't actually find a source of the error because the onclick events say they should call the right methods but they don't. But on the topic of a Unity restart, I have restarted Unity but do you think this issue could be caused by Unity not being updated to the latest update?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

158 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 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

OnClick() animation 0 Answers

How do I make a function not appear on UnityEvents / Button OnClick lists? 0 Answers

Button OnClick() calling wrong function 1 Answer

How do i make the perfect button? 1 Answer

Animation works only once on button click 4 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