I can't click on a sprite

Hello,

I have a problem on my project.
I made a worldmap with sprites, and for beginning,i just want to change the color of any sprite by clicking on it.
Here is the code i used :

private SpriteRenderer spriteRenderer;

    // Use this for initialization
    void Start () {
        spriteRenderer = GetComponent<SpriteRenderer> ();
        spriteRenderer.color = new Color(1F, 0.91F, 0.5F, 1F);
    }

    void onMouseDown(){
        Debug.Log ("mouse down");
        spriteRenderer.color = Color.red;
    }

    void onMouseOver(){
        Debug.Log ("mouse down");
    }

The color of the sprite is changing when the game is launching, but nothing happens on click or when the mouse is over the sprite.

I decided for test to create a new scene. I just added only one sprite in it. I add polygon collider to the sprite (as I did in my main scene for each sprite), with isTrigger on.
I attached my script to the sprite, and nothing happens …
I add a RigidBody2D, with isKinematic on, but it didn’t change the result.

Something probably obvious is missing, but I don’t see what.

Try to chande code:
OnMouseDown
OnMouseOver

1 Like

Thanks, it was this …
This is what happens when you work all the day on another programming language :stuck_out_tongue: