Sounds like a yes or no question, but I did want to extrapolate. It’s more of an optimization question.
If yes, what would be a good way to spread calculations out across a few different frames to reduce performance spiking?
Should I place a yield return new WaitForEndOfFrame();
between calculations? Does this do what I want? Is there another more proper way?
The reason I ask is, while I’m not doing anything particularly heavy, I do have a lot happening that I think is currently all being calculated in one frame, leading to uneven performance.
Example:
Will this,
IEnumerator Test_Coroutine()
{
var1 += 1;
yield return new WaitForEndOfFrame();
var2 += 1;
yield return new WaitForEndOfFrame();
var3 += 1;
yield return new WaitForEndOfFrame();
var4 += 1;
}
…result in smoother performance than just running all 4 calculations in the same frame, or is this an incorrect use of WaitForEndOfFrame? (For the sake of the example, I’m well aware that adding 1 to a variable isn’t a hard calculation. Pretend I’m doing something more advanced in place of these. :))
Thanks for any help. It’s really just a clarification that I need, and hopefully it’ll help anyone else with similar questions.