unity2d click on gameobject

Code Example - unity2d click on gameobject

                
                        // Object must have a collider and this script attached to the object
    private void OnMouseDown()
    {
        Debug.Log("Clicked on object!");
    }