Hi, I am having real trouble with getting my mouse to change the currently selected button to whichever button is currently highlighted.
The reason is that I use gamepads as well as mouse / keyboard, and the UI is set to make the first button active. However, if you hover over another button with the mouse, you have two highlighted buttons.
I am trying to use the following code, but it simply doesnt work.
using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class MouseSelector : MonoBehaviour, IPointerEnterHandler {
public void OnPointerEnter(PointerEventData eventData)
{
EventSystem.current.SetSelectedGameObject(eventData.pointerCurrentRaycast.gameObject);
}
}
This should work, but the OnPointerEnter event never triggers, even if I just chuck a debug.Log hello in there.
The mouse must be working as the buttons highlight, I simply cannot hook into that and use it.
Any ideas / thoughts?