Note the mentioned link that makes this link a duplicate is asking about "How to detect UI object on Canvas on Touch in android?", which is not what my question is about.
I have a scene that only has Unity UI elements.
the UI elements are (essentially) a list of Images, each with a Text as a child.
The Text is a word.
I then created a separate Image (background) with Text, that I want to appear when the mouse is hovering over the particular word, then disappear when the mouse is not hovering over the particular word.
Each UI item has been manually created in the scene.
The issue is that options "OnMouseEnter" and "OnMouseExit" don't work.
my script:
using UnityEngine;
using UnityEngine.EventSystems;
public class MouseEnablePopupWindow : MonoBehaviour
{
public GameObject popupWindowObject;
private void Start()
{
popupWindowObject.SetActive(false);
}
private void Update()
{
}
private void OnMouseEnter()
{
print("OnMouseEnter");
popupWindowObject.SetActive(true);
}
private void OnMouseExit()
{
print("OnMouseExit");
popupWindowObject.SetActive(false);
}
}
The only items in the scene are UI items (canvas, image, text).
The Start method successfully makes the reference game object as inactive. but hovering over or away does nothing.
I'm wondering why the "OnMouseEnter", etc., mouse input handling code doesn't work. Every post I've found on the web regarding the subject involves writing a completely different way of handling input.
Why won't the built-in functionality work? Any ideas? Thanks.