I don’t understand why my public method having the same signature with UnityAction like this:
public void mouseEnterHandler(PointerEventData e){
//…
}
//or even like this
public void mouseEnterHandler(BaseEventData e){
//…
}
does not appear in the functions list of the EventTrigger?
Isn’t that the internal callback (added by AddListener) has type of UnityAction? So it should work. Currently looks like only functions having arguments of basic data type (int, string, object, ) or no arguments are listed and choosable.
Could you explain to me why is that strange? So how could the PointerEventData be passed that way? I’m currently using Unity 4.6.1f if that matters.
Thank you all for your help.
As I understand the chosen function from the list will have its arguments fillable via some auto generated fields in the Inspector. So in the case of PointerEventData, there is no way to supply an instance of that type at design time. So it will be blocked from being chosen. Looks like EventTrigger just does half of the job it should have been able to do. I find it a little convenient and quick way of hooking some event handler without having to prepare and add my own component. But looks like it’s very limited. Also to use it, only exposed public methods can be chosen. While normally handlers should be all private. I don’t like the idea of exposing everything just to hook it up with the EventTrigger this way. It’s just a mess.