Touch 2D Sprite Problem !

Hi
I ceated 2d sprite and i want make it a button, when i touch it, do something, the code compile with no errors, but the code not worked !

using UnityEngine;
using System.Collections;

public class buttonPower : MonoBehaviour {
private Collider2D c2d;

    void Start ()
    {
        //Declare the rigidbody within the script
        c2d = GetComponent<Collider2D>();
    }

    void Update()
    {
        if (Input.touchCount == 1)
        {
            Vector3 wp = Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position);
            Vector2 touchPos = new Vector2(wp.x, wp.y);
            if (c2d == Physics2D.OverlapPoint(touchPos))
            {
                Debug.Log ("Hi");
            }
        }
    }
}

Physics2D.OverlapPoint will return the first collider it sees at that point so if you have more than a single collider, you won’t necessarily get the one you want.

If you use Collider2D.OverlapPoint then it’ll check if the point overlaps that specific collider.

If this doesn’t work then it must be that the point you’re getting correct so it’s worth dumping it out to the console and checking. Also note that Unity will implicitly convert a Vector3 to a Vector2 for you (drop the Z) so you don’t need to create a Vector2 as you are doing.