• 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
1
Question by philipyeung · Nov 06, 2016 at 10:37 AM · uiraycastcanvasgameobjectseventsystem

OnPointerEnter blocked by something

I have my project setup like this:

  • Main Camera
    • Physics 2D Raycaster
      • Event Mask: Everthing

  • Canvas
    • Graphic Raycaster
      • Blocking Objects: None

      • Blocking Mask: Nothing

2 Objects setup:

  1. GameObject
    • Sprite Renderer

    • Rigidbody 2D

    • Circle Collider 2D

    • (my GO script)

  2. UI
    • Image

    • Button

    • (my UI script)

In both my GO and UI script, I add events like OnPointerEnter,etc. Everything work fine. I have my pointer enter event on both object. But when I use a joint to drag a GO object and move to top of the UI object. My UI object OnPointerEnter blocked. I search on web and everybody ask for blocking raycast on GO to UI. But I need the reverse, I want both GO and UI receive all events normally when any object overlap. Any hints?

Comment
Add comment · Show 4
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 Zynek · Nov 06, 2016 at 12:47 PM 0
Share

Not sure if i get it right, but maybe just add triggers to your UI to trigger the event in game object ?

avatar image philipyeung · Nov 06, 2016 at 10:07 PM 0
Share

Hi Zynek, Thanks to your advice and it seems is a way out. But when I add a rigibody2D and 2Dcollider(is trigger) on the UI object. The OnTriggerEnter2D didn't received event. I don't know if I do something wrong. Is it work to add trigger system in unity UI? P.S. my GO object already implement trigger system and work fine.

avatar image philipyeung · Nov 06, 2016 at 11:42 PM 0
Share

Thanks Zynek. the trigger system not work because I adding them as child of UI (seems my setting problem). But when I add them as component of UI, everything fly.

avatar image luislodosm · Feb 16, 2017 at 12:38 AM 0
Share

Deactivate option "Raycast Target" in the UI elements that could block the Physics 2D Raycaster.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by philipyeung · Nov 06, 2016 at 11:40 PM

Finally get what I want by taking Zynek's suggestion. I add rigibody2D(isKinematic and Freeze xyz) and 2Dcollider(is trigger) as component in UI object. OnTriggerEnter2D receive my GO collider and done. But I still curious why I cannot make both GO and UI get my pointer/touch OnPointerEnter.

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
avatar image
0

Answer by Zynek · Nov 07, 2016 at 07:35 PM

I´m sorry i misled you. What i meant is to add Event Trigger to UI as i did in this picture:

alt text

U just add pointer enter and pointer exit events and set methods you want to call when it occurs. In my case im calling method that sets boolean onGui to proper value.


eventtrigger.png (14.2 kB)
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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

125 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

Related Questions

Making UI block rays with touch inputs 0 Answers

UI Button not working? 0 Answers

Laser pointer style UI interaction in VR 2 Answers

Unity Button reacts even if Canvas is disabled 0 Answers

If I disable/enable my canvas (pause game menu), controller navigation in the canvas stops to work? 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