what's wrong with this do-while loop? it frezes while I'm on playmode
IEnumerator ClearAndRefillBoardRoutine(List<GamePiece> gamePieces)
{
m_playerInputEnabled = false;
List<GamePiece> matches = gamePieces;
do
{
yield return StartCoroutine(ClearAndCollapseRoutine(matches));
yield return null;
yield return StartCoroutine(RefillRoutine());
matches = FindAllMatches();
yield return new WaitForSeconds(0.5f);
}
while (matches.Count != 0);
m_playerInputEnabled = true;
}
Well, even if Count never reaches zero, the yield return's would 'release' from inside that loop, presumably at each Update call (as a coroutine).
I don't believe the freeze comes from this loop. The problem may come from the ClearAndCollapseRoutine
or FindAll$$anonymous$$atches
Yes, the OP must post the rest of that code in order for anyone to be able to help.
Along with the other comments (post the other code to get more help), it would help to know what the overall plan is for this code because there may be better approaches.
Depending on what you're really doing, it may perform better in a thread (or threads) than as a coroutine, though that comes with all the caveats regarding threaded program$$anonymous$$g. There's a reason modern machines have multiple CPU's and it only serves us to use them when appropriate.