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");
}
}
}
}