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 DCTShinobi · Nov 30, 2014 at 07:29 AM · uicanvaseventpointeroverlay

How do Pointer events work? 4.6 UI

I understand how to place event triggers on the new UI objects, but I don't understand how some of their mechanics work.

For one, do the Pointer events (Enter, Exit, Drag, etc.) use colliders to determine if the cursor is over the particular object? I have placed events on panels, and they work well, but I do not put any colliders on those panels. If they don't use colliders, then how do they do work?

I've been using a canvas set to Screen Space - Overlay. Pointer events work well and accurately. But when I use a MouseOver function on the same object, even with a collider, Unity doesn't recognize when my cursor is over it... unless the object itself is truly in front of the camera (unlike the Pointer events that recognize the overlay's positioning). Why is that? How can I solve that?

Is there a way to edit how a Pointer event works so I can tweak it to my need or at least see how it works so I can apply those methods to my own scripts? Is there a way to determine if my cursor is over an object (and only the front object if there are objects behind it) without using a collider?

And, most importantly, is there a PointerOver event hiding anywhere?

Thank you!

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Dr-Nick · Sep 09, 2015 at 11:25 AM

The idea behind pointer events is to make life easier to manage input from mouse and touch screen input. Rather than you having to manage ray caster into the game world and worry what you're interacting with, you only have to worry about is how to manage input interaction on game objects when it happens. The way the scene detects input is via RayCaster components.

For interaction UI components, you need to put a Graphics Raycaster on a canvas. For interaction for 2D and 3D physics components you need a Physics2DRaycaster and PhysicsRaycaster respectively on the camera which is viewing your scene.

If you want objects in your scene to be interacted with by the respective ray caster, 2d and 3d objects need a respective 2d or 3d collider and for the ui, all ui components can be interacted with by default unless component is deactivated or they have a parent canvas group component that doesn't block ray casts.

You will also need to be aware what layers your objects are on and what layers your ray casters can interact with. Basically you can ignore objects on certain layers if you try and click on them.

As for PointerOver - I believe event you want is the PointerEnter event. It will fire when your pointer is over an object it can interact with.

If this doesn't answer your question properly then let me know.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

World Space Canvas not rendering in front of Overlay Canvas 0 Answers

Using a 3D model as a button, in Unity's UI system? 3 Answers

Get Global PointerEventData 1 Answer

Screen Space - Camera to Screen Space - Overlay switch issue 0 Answers

problem with canvas 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