- Home /
Question by
epark3 · Oct 27, 2017 at 04:20 AM ·
guigui-buttonpointer
ExecuteEvents.Execute makes game crash
What my game looks like: basically a bunch of buttons
What I want to do: if you hover your mouse over a button, it will highlight a different button as if there was another pointer hovering over the second button.
My attempt:
public class ButtonScript : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler {
....
public void OnPointerEnter(PointerEventData eventData) {
Button test = GameObject.Find ("secondButton").GetComponent<Button> ();
PointerEventData pointer = new PointerEventData(EventSystem.current);
ExecuteEvents.Execute (test.gameObject, pointer, ExecuteEvents.pointerEnterHandler);
}
....
}
Results: Program pauses/crashes.
The thing is, when I move ExecuteEvents.Execute into a different function, like OnPointerClick or OnPointerExit, everything is fine. What can I do to achieve what I want?
Comment