So i'm using Kinect with unity to track user's hand movements, and let the user's hand act as a mouse, I have written the code to detect a collision between a button (sprite object) and the hand cursor using OnTriggerEnter2D, but I want the hand cursor to remain on the button (sprite object) for atleast 3 seconds for it to be considered as a button click action. The WaitForSeconds coroutine doesn't seem to be working. What am i doing wrong?
public class MenuSelect : MonoBehaviour{
private string btnName;
private string themeName;
// Use this for initialization
void Start ()
{
//gestureListener = Camera.main.GetComponent<GestureListener>();
}
// Update is called once per frame
void Update ()
{
}
void OnTriggerEnter2D(Collider2D col)
{
//print("Collision Detected");
StartCoroutine(WaitTime(3));
if(col.gameObject.tag == "Button")
{
btnName = col.gameObject.name;
switch(btnName)
{
case "musicBtn":
Application.LoadLevel("Menu_Music");
break;
case "startBtn":
Application.LoadLevel("Menu_Select");
break;
case "instructBtn":
print("Instruction Clicked");
break;
case "exitBtn":
Application.Quit();
break;
case "themeBtn":
Application.LoadLevel("Menu_Theme");
break;
case "backBtn":
Application.LoadLevel("Menu_LoadScreen");
break;
}
}
}
IEnumerator WaitTime(float waitTime)
{
yield return new WaitForSeconds(waitTime);
print("seconds up already");
} }