0
\$\begingroup\$

I implemented the IPointerClickHandler in a script that runs on multiple GameObjects in my scene. I'm definitely missing something since the implementation is not being called at all. The objects are not UI elements. Here is the implementation of the interface :

 public void OnPointerClick(PointerEventData eventData)
 {
      Debug.Log("clicked on " + eventData.selectedObject.name);
 }

Can I even use the EventSystem with normal GameObjects? If I can how do I do it.

What i tried: Adding a BoxCollider2D to the object, using the event trigger component on the object calling a public method.

Edit: I was missing a raycaster on the main camera.

\$\endgroup\$
2
  • \$\begingroup\$ Don't answer your questions inside the question body. Post your answer instead as an answer, so that others can find the help too. \$\endgroup\$
    – user35344
    May 3, 2016 at 8:34
  • \$\begingroup\$ @Tyyppi_77 yeah again sorry about this. I just got to work after a 4 day weekend and I'm not in the zone so to say :D \$\endgroup\$
    – Uri Popov
    May 3, 2016 at 8:51

1 Answer 1

0
\$\begingroup\$

Turns out i was simply missing a RayCaster component attached to my main camera. In my case I had to use the Physics 2D Raycaster.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .