• 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 Dragunas · Feb 12, 2021 at 01:11 PM · not workingtooltip

Why is it not detecting OnPointEnter

so i followed a tutorial from youtube and i made this Script: using System.Collections; using UnityEngine; using UnityEngine.EventSystems; using System; using UnityEngine.UI;

 public class ItemSlot : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
 {
 
     private Item _item;
 
     public Item Item
     {
         get { return _item; }
         set
         {
             _item = value;
             if (_item == null)
             {
                 image.enabled = false;
             }
             else
             {
                 image.sprite = _item.Icon;
                 image.enabled = true;
             }
         }
     }
     [SerializeField] Image image;
     [SerializeField] ItemToolTip tooltip;
 
     protected virtual void OnValidate()
     {
         if (image == null)
             image = GetComponent<Image>();
 
         if (tooltip == null)
             tooltip = FindObjectOfType<ItemToolTip>();
     }
     public void OnPointerEnter(PointerEventData eventData)
     {
         Debug.Log("Slot Detected!");
         if (Item is EquippableItem)
         {
             tooltip.ShowTooltip((EquippableItem)Item);
         }
     }
 
     public void OnPointerExit(PointerEventData eventData)
     {
         Debug.Log("You Exit");
         tooltip.HideTooltip();
     }
 
 }

my problem is that it is not detecting the OnPointEnter method and i am not getting my Debug:log if i hover with my mouse above my "Slot" object alt text

unitydetecting.png (72.4 kB)
Comment
Add comment · Show 1
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 AllTheGoodNamesWereTaken · Feb 12, 2021 at 05:41 PM 0
Share

That should be working, try making sure that there's no window (Invisible or otherwise) above your slot object (possibly blocking raycast). $$anonymous$$aby also try turning off maskable for a sec.

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Elango · Feb 12, 2021 at 05:39 PM

IPointerEnterHandler/IPointerExitHandler are correctly implemented and should work fine.

1 - IPointerEnterHandler/IPointerExitHandler is part of EventSystems and will not work without it. Make sure there is an EventSystem on the scene.

2 - At least one parent object (usually Canvas) has a Graphic Raycast component and it is enabled.

3 - There is no other UI element with Raycast Target enabled that covers the slot with its position and size, and it is placed in the hierarchy lower than the slot.

Comment
Add comment · Show 1 · 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 Dragunas · Feb 12, 2021 at 05:53 PM 0
Share

Omg i am so dumb i forgot my EventSystem for my scene xD, sorry for wasting your time

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

113 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

Related Questions

How to make my badguy freeze when he hit me? 1 Answer

Error Script, Not found class GameObject 1 Answer

Unity Won't Build Android 0 Answers

OnTriggerEnter not working in running game 4 Answers

Quaternion slerp not fully rotating 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