I am able to detect a click on a cloned game object if I use the “Send Messages” option. I attach a Physics Raycaster 2D to my camera, implement an IPointerHandler, and it works great. But this method detects two events – started and performed – rather than just the one I need. And I can’t find a way using eventData to weed out “started” from “performed” clicks.
I see that CallbackContext (used with the “Invoke Unity Events” option) can distinguish between those two types of events. Moreover, in general I’d prefer to use the “Invoke Unity Events” option, as it seems more flexible.
But I can’t get the “Invoke Unity Events” option to properly detect a click on a cloned game object. I can get the mousePosition easily enough, but then I have to do cumbersome math to figure out which game object is being clicked. The CallbackContext parameter returns the name of my generic prefab, not the specific name of THIS instantiated game object, even if I use this.name. Likewise, the parameter returns integer variables always set to 0, not the value held in the prefab object. Is there a way to do this using “Invoke Unity Events”, or am I stuck using “Send Messages”, which sends two click events?