Skip to main content
deleted 23 characters in body
Source Link
Theraot
  • 28.3k
  • 4
  • 55
  • 83

The routine won't stop on its own because, as you said, the while loop is infinite. Instead, replace the truetrue in while(true)while(true) with a boolbool variable that you can set either inside or outside of the coroutine.

Bool allowFlicker =true While(allowFlicker) { // do stuff here

//time to stop? Then set allowFlicker false AllowFlicker = false }

bool allowFlicker =true
while(allowFlicker)
{
    // do stuff here

    //time to stop? Then set allowFlicker false
    allowFlicker = false
}

This looks like it could also be simply placed in the updateUpdate or fixedupdateFixedUpdate functions.

typed on my phone before sleep, excuse formatting

The routine won't stop on its own because, as you said, the while loop is infinite. Instead, replace the true in while(true) with a bool variable that you can set either inside or outside of the coroutine.

Bool allowFlicker =true While(allowFlicker) { // do stuff here

//time to stop? Then set allowFlicker false AllowFlicker = false }

This looks like it could also be simply placed in the update or fixedupdate functions.

typed on my phone before sleep, excuse formatting

The routine won't stop on its own because, as you said, the while loop is infinite. Instead, replace the true in while(true) with a bool variable that you can set either inside or outside of the coroutine.

bool allowFlicker =true
while(allowFlicker)
{
    // do stuff here

    //time to stop? Then set allowFlicker false
    allowFlicker = false
}

This looks like it could also be simply placed in the Update or FixedUpdate functions.

Source Link

The routine won't stop on its own because, as you said, the while loop is infinite. Instead, replace the true in while(true) with a bool variable that you can set either inside or outside of the coroutine.

Bool allowFlicker =true While(allowFlicker) { // do stuff here

//time to stop? Then set allowFlicker false AllowFlicker = false }

This looks like it could also be simply placed in the update or fixedupdate functions.

typed on my phone before sleep, excuse formatting