Question by
sholom1 · Apr 20, 2018 at 07:53 PM ·
loopinfiniteinput.getbutton
Input.GetMouseButtonDown(0) causing infinite loop in corotine?
public IEnumerator listenForClick(){
bool clicked = false;
while (!clicked) {
yield return null;
//this gets called until i click
Debug.Log ("Listening for click");
if (Input.GetMouseButtonDown (0)) {
//HERE Debug.Log("Click"); is never called and unity freezes
Debug.Log ("click");
Ray ray1 = CamController.Instance._camera.ScreenPointToRay (Input.mousePosition);
RaycastHit hit1;
if (Physics.Raycast (ray1, out hit1)) {
selectedPerson.AddTask (hit1.collider.gameObject.GetComponent<Square> ().x, hit1.collider.gameObject.GetComponent<Square> ().y, Job.Move);
clicked = true;
//break;
}
}
}
}
Comment
not caused by input.getmousebuttondown any other key produces the same result