I have a few nested loops, and I need the innermost one to wait until a button has been pressed. Don't know why the solution is escaping me, but can somebody please help me out here?
for (roundNo = 1; roundNo <=3; roundNo ++) //start of the round
{
if(!isBoardSet)
{ Debug.Log("RoundNo = "+roundNo);
var board_new = GameObject.Find("board_new");
var randDist: float; //distance for the new board
randDist = Random.Range(9.0, 12.0)/3.2808398950131234 ; //this is 9 - 12 feet converted to meters
board_new.transform.position =Vector3(randDist, .156, 0);
for (var playerNo: int = 1; playerNo <= noPlayers; playerNo ++) //start of the player's turn
{ Debug.Log("playerNo = "+playerNo);
for (var tossNo: int = 1; tossNo <= 3; tossNo ++)
{ Debug.Log("tossNo = "+tossNo);
if (tossed) Debug.Log("tossNo = "+ tossNo);
//put in x and y vel
//var textFieldString = "Enter x vel";
}//we need it to wait here and poll the Toss It button
}
isBoardSet = true;
}
xVel = GUI.TextField (Rect (140, 40, 120, 20), xVel);
yVel = GUI.TextField (Rect (140, 70, 120, 20), yVel);
//Debug.Log ("xVel = "+xVel+ " yVel = "+yVel);
GUI.Box (Rect (10,180,100,150), "Progress");
GUI.Label(Rect(10, 210, 80, 20), "Round: "+ roundNo);
GUI.Label(Rect(10, 240, 80, 20), "Player: "+ playerNo);
GUI.Label(Rect(10, 270, 80, 20), "Toss: "+ tossNo);
if (GUI.Button (Rect (140,100,80,20), "Toss It"))
{
//call some function in trajectory2
tossed = true;
}
} //end of the round
Not sure, but do I need a coroutine and a yield?
asked
Jun 29 '10 at 11:36 PM
Jeff Ciaccio
277
●
28
●
37
●
48