How to make 2D Objects trigger script when clicked

Hey there!

I’m trying to accomplish something quite simple, but somehow i just cannot figure it out.

I have a 2D Object in my scene. When i click it (incl. releasing the mouse button), i want it to run a script that is attached to that object.
The object has a Box Collider (2D) attached, Is Trigger is activated.
Further i attached an Event Trigger component and set it to PointerClick to run the following action inside of the attached script:

public void RunMe ()
{
Debug.Log (“The object has been clicked”);
}

Everything looks fine, but the action is just not being executed when the object is clicked… Any ideas what might be wrong in this scenario?

Make sure that:

  • the collider is properly scaled
  • there is an EventSystem in your scene with an active InputModule
  • there is a Physics2DRaycaster on your camera