Hello guys,
I played around with the new UI and found something annoying, there is a built in system to call a function when you click on a button with the keyboard or with the mouse, but i didnt find anything to do the exactly same with highlighting to for an example play a sound when you put the mouse over or select it with keyboard, can someone give me a work around or a guide line to this?
Thanks.
There are lots of events you can use on controls, and adding an EventTrigger lets you respond to a lot more events than just OnClick().
If you prefer to make a convenient component you can drop on buttons which give off noise on selection, this’ll work too:
using UnityEngine;
using UnityEngine.EventSystems;
public class Ping : MonoBehaviour, ISelectHandler
{
public void OnSelect(BaseEventData data)
{
// Play the sound here
}
}
I Found a workaround using EventTrigger and OnPointerEnter you can also do what orb said by putting this i believe
public void OnPointerEnter(BaseEventData data)
{
// Play the sound here
}
Thanks orb for your time