0
\$\begingroup\$

So i have the following setup:

enter image description here

This produces the following UI:

enter image description here

Now on each of the "HudCircle"(Bottom/Right/Left/Top), I have the following components:

enter image description here

As you can see I have a script that has the following code:

    public class HUDAction : MonoBehaviour,  IPointerEnterHandler, IPointerExitHandler
{
    public Color StartColor;
    public Color SelectedColor;
    public Image Image;

    private void Awake()
    {
        Image = GetComponent<Image>();
        StartColor = Image.color;
    }

    public void OnPointerEnter(PointerEventData eventData)
    {
        Image.color = SelectedColor;
        Debug.Log("Over");
    }

    public void OnPointerExit(PointerEventData eventData)
    {
        Image.color = StartColor;
        Debug.Log("Not over");
    }
}

Sadly when playing this scene nothing happens when I hover either of the circles.

Can anyone tell me what I've done wrong?

\$\endgroup\$
1
\$\begingroup\$

The Image component needs to have the Raycast Target checkbox checked. I assume you have an EventSystem GameObject somewhere in the hierarchy to handle sending the events as well. If not, you’ll need one of those too.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.