Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by itWouldBeWise · Mar 08, 2015 at 12:11 PM · uievent4.6handling

4.6 UI EventSystem Handler Redirection?

So here's the situation:

I have a UI Panel with a bunch of UI Images as children. I would like those images to respond to dragging, clicking, double-clicking, etc, so adding a script to them that implements IBeginDragHandler, IPointerClickHandler, etc. would make for a beautiful solution.

BUT here's the catch: The UI "colliders" for these images are rectangular (and match the bounds of the sprite if I'm not mistaken), which means that if you have 2 images stacked on top of each other, the mouse interactions are intercepted by the top one even in the transparent areas of that image. First off, I believe I have a solution to determine which image the mouse should actually interact with: By using EventSystem.current.RaycastAll and then iterating through the results and comparing the intercept locations for each image with the corresponding pixel value at that location to determine if it is an opaque pixel or not, I can locate the top-most image where the mouse cursor is actually over the opaque part of the image...

What I'm having trouble with is this: How can I control the flow of a given drag/click event to apply to the correct IBeginDragHandler, IPointerClickHandler etc based on the above pixel-perfect approach to finding the true image under the cursor? It seems to me that the functions implemented by the IBeginDragHandler/IPointerClickHandler are always called on the first encountered object and I'm having a difficult time figuring out if / how it's possible to somehow re-route those events such that they pass through to the correct image per my above pixel-perfect "mouse over" detection. I hope it is possible to still rely on those interfaces somehow rather than implementing my own drag/click functionality in this situation (it seems so much more elegant)!

Thanks for any assistance or direction you can provide!

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

0 Replies

· Add your reply
  • Sort: 

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

2 People are following this question.

avatar image avatar image

Related Questions

How to use the deselect Event Trigger? 1 Answer

4.6 UI OnBeginDrag event handler doesn't seem to work. 1 Answer

4.6 UI "image" is capturing clicks - how to prevent? 3 Answers

[4.6 - UI] How to call an event with button when the pointer is up the button image. 1 Answer

4.6 UI Dynamic button event system PointerEnter, PointerExit, PointerUp etc. 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