• 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 /
avatar image
Question by The-It · Mar 11, 2020 at 09:27 AM · clickmonobehaviourmouseclickonmousedownonmouseup

Click detection suddenly stopped working

I'd like to start off by apologising for the overly vague question. Unfortunately, this project contains a lot of code and I have no idea which part of it could be the problem so naturally I have no idea which parts of the code to post. Let me know if there is something specific I should be posting here...

I'm posting this question to see if anyone know why this might be occurring or where I should look in my project to try and get this resolved or if anyone knows any way to debug this because this doesn't make any sense to me what so ever...


That said, here is the problem:

I have a bunch of prefabs that are instantiated at run-time and their supposed to behave a certain way when clicked (or touched since this is going to be a phone app eventually). I got this to work with OnMouseDown() no problem. After working on the project a bit and implementing things which as far as I can tell are completely unrelated this, it seems that now no matter where I click, it will detect the click as though it came from the first of the instantiated prefabs. Furthermore, when I delete that one from the editor or disable the collider, it seems to pick another at random to be the only one to detect and click and detect it even if I haven't clicked on this.


The most frustrating thing about this entire situation is that even when I revert all changes I made, I can't get it to work like it did before and I have no idea why!


So yeah, thanks for reading and thanks in advance for any help!


UPDATE: Thanks to @streeetwalker, I now realise the prefab with the lowest z value is always the one stealing clicks. Initially I made them spawn with a z value of 0, I tried changing it so that they're all unique, all positive, all negative, nothing seems to change the fact that the gameobject with the lowest z is stealing all the clicks! So bizarre that that wasn't happening before

Comment

People who like this

0 Show 6
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 streeetwalker · Mar 11, 2020 at 11:56 AM 0
Share

Is this in 3d or 2d? and what are 'thins' ?

avatar image The-It streeetwalker · Mar 11, 2020 at 11:59 AM 0
Share

2D. Was just working on the project. I know, this is super vague and not very helpful, but actually there were a lot of things I added in between when it stopped working and when it didn't, but like I said as far as I can tall none of them had anything to do with the prefabs or how they operate

avatar image streeetwalker The-It · Mar 11, 2020 at 12:30 PM 0
Share

What are thins?

2D is a bit different. Sounds like something in front is stealing clicks. If everything has the same z axis value, this is a frequent problem. What gets the MouseDown seems random.

Have you tried making sure that your objects, such as backgrounds are at different z values? I think the default is -z vlaues are closer to the camera than +z.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by The-It · Mar 13, 2020 at 03:09 AM

The problem was for some reason that the edge radius on the collider in the prefab was set to an obscenely high number so it was taking up the entire canvas.

Comment

People who like this

0 Show 0 · 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

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

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

I want to only open the keyboard when im using an inputfield onmouseup not onmousedown 1 Answer

Play more animations onclick 1 Answer

Turn on and off sound on mouse click C# 1 Answer

Why my input both mouse and touch can't detected? 0 Answers

OnMouseDown/Drag/ets is not being called in WebGL build 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