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 nicmarxp · Feb 24, 2019 at 10:21 PM · uiraycastbuttons

UI: Tooltip for multiple images behind bigger button?

I have a crafting window with a couple of images for a crafting recipe. When I hover each, I see a tooltip of what it is, but on top of all images I have a bigger button that I can click to craft that item. I could make each image clickable, but I'd like the button/border of all icons to be highlighted when hovered.

I'm using IPointerEnterHandler to receive mouseover events to show the tooltip. But when there is a button on top of it, the OnPointerEnterEvent doesn't fire.

Is there a way to combine these, so the raycast still goes through to the IPointerEnterHandler, and at the same time the button works like a normal button?

Or do I have to code my own solution with raycasts, like "if mouse is over any icon, show border", "if anything is clicked, craft item".

Thank you in advance!

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
0

Answer by kaplica · Feb 24, 2019 at 10:33 PM

Can you not use triggers? https://docs.unity3d.com/ScriptReference/EventSystems.EventTrigger.html

Update

I know what you mean now, sorry. I am using this script for my sidebar navigational menu in my app, it helps me to pin point what user taps on.

 if (Input.touchCount > 0)
         {
             var touch = Input.GetTouch(0);
 
             PointerEventData pointerData = new PointerEventData(EventSystem.current);
 
             pointerData.position = touch.position;
 
             List<RaycastResult> results = new List<RaycastResult>();
             EventSystem.current.RaycastAll(pointerData, results);
 
             if (results.Count > 0)
             {
                 if (results[0].gameObject.layer != LayerMask.NameToLayer("UI - Sidebar"))
                 {
                    Debug.Log("Root Element" + results[results.Count-1].gameObject.name + " Child" + results[0].gameObject.name);
                     results.Clear();
                 }
             }
         }

Comment
Add comment · Show 3 · 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 nicmarxp · Feb 25, 2019 at 07:28 AM 0
Share

Thanks, I will check it out. But does this allow events to pass through layers of UI elements, so I can have a "OnPointerEnter" on the image and at the same time "On$$anonymous$$ouseDown" on the button that is above?

avatar image kaplica · Feb 26, 2019 at 09:50 AM 0
Share

Please see my updated answer. This has to be ran every frame by the way, so in Update, or FixedUpdate if you want it to run at the end of each frame.

avatar image nicmarxp kaplica · Feb 26, 2019 at 10:08 AM 0
Share

Thanks a lot, will try and confirm the answer when I find that it works :)

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

198 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

Related Questions

How to use two Canvases in Unity 4.7 ? 0 Answers

Buttons and Event Triggers kill FPS 0 Answers

How i set image from Raycast hit target object? 2 Answers

Display issues with GUI only showing details for last object in list. 2 Answers

Different between IPointerClickHandler.OnPointerClick and MonoBehaviour.OnMouseDown 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