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 /
avatar image
0
Question by alexjolig · Sep 20, 2017 at 04:21 AM · canvasonclick

UI object catches click event even by clicking outside of that object

I'm running to a weird issue where I have a Canvas and some objects on it which are adding as prefabs. Each object has a OnClick event attached to it. The problem comes in when I click somewhere in Canvas only to see one of those prefabs catch the click event (and I don't know which one got it).

The whole thing was working good, till it wasn't anymore. I'm not sure if I did somthing or maybe it happens after updating Unity.

Has anyone ran to this issue before or has any idea why this would happen?

UPDATE

Here's some more details:

  • I guess the problem happened after installing Unity Pro 2017.1

  • I've changed the ordering layers in some different ways and problem still was around!

  • Maybe it worth mention that the prefabs are adding to a parent with grid layout group.

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 hexagonius · Sep 20, 2017 at 09:28 AM 0
Share

to catch an event some UI element has to be in that place. Check the position you've clicked at during play mode when you click it and something received the click. Reduce the amount of UI elements one by one, or start with just one and enable few more, all during play mode. You'll find it.

avatar image alexjolig · Sep 21, 2017 at 03:53 AM 0
Share

@hexagonius Thanks for the reply. But I did as you said and the object still catches the click wherever I click on the Canvas. I'm starting to think it as a weird bug in Unity Pro 2017.1

avatar image hexagonius alexjolig · Sep 21, 2017 at 06:23 AM 0
Share

Do even without any UI elements active you receive a click event? Are you using the event System it the input class?

avatar image alexjolig hexagonius · Sep 21, 2017 at 06:50 AM 0
Share

@hexagonius The problem stays until I remove the last prefab which has the script for receiving click event. After removing all those prefabs, nothing happens. I'm using IPointerClickHandler if that's what you asked.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by jtok4j · Sep 20, 2017 at 10:40 PM

Hi, Check the sorting layers of your canvas, and see which objects are higher/lower in comparison with the others. It may also be that the main Canvas area is detecting the clicks. However, to be sure/narrow down the culprit, add this debug.log to each object's script (the objects on the canvas, which you are trying to click:

 Debug.Log("Detected Click on", gameObject);

This way, the console window in your Unity Editor, will print out the message from the clicked object, and you can tell what's intercepting the clicks. A bit of work, but well worth it.

Good Luck!

Comment
Add comment · 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.

Follow this Question

Answers Answers and Comments

76 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

Related Questions

void dont show up in on click 1 Answer

button OnClick function triggering another buttons OnClick 0 Answers

Click on box collider on an image in a canvas 0 Answers

Canvas button with 2 functions onClick must be pressed twice for 2nd function? Will not disappear? 1 Answer

How to make it so only a certain section of a button will work on click 1 Answer


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