Unity:如何暂停执行,直到函数终止,以便跳过任何帧 [英] Unity: How to pause execution until function terminates, so as to skip no frames
问题描述
然而,当游戏在写完后恢复游戏时,游戏会跳过几帧。
我需要Unity 跳过绝对无框是如此。如何强制Unity引擎在写入完成前停止执行,以便在恢复时不会跳过任何帧?
为了提供一些上下文,我将捕获每帧的截图,并将它们作为Texture2D存储在队列中。当队列中有超过100帧的Texture2D时,我将它作为PNG写入磁盘,然后清除队列。
我想暂停渲染/执行,同时写入发生,以便输出(单独)无缝。
您可以将timeScale设置为0,以便不调用Animation和FixedUpdate。
添加一些检查: void Update()
{
if(Manager.cleaningTexture == true ){return; }
//其余的代码
}
I am writing a game/program which every few seconds has to write a lot of data to the hard disk - this takes a few seconds to complete, and naturally causes the game to hang for that duration.
However, when the game resumes after the writes have completed, the game skips a few frames.
I need it that Unity will skip absolutely no frames what so ever. How can I force the Unity Engine to stop executing until the writing has fully completed, so that when it resumes, no frames have been skipped?
To provide some context, I am capturing a screenshot every frame, storing them as Texture2Ds in a queue. When the queue has more than 100 frames worth of Texture2Ds in it, I am writing the to the disk as PNGs, and clearing the queue.
I want to pause rendering/execution whilst the writing takes place so that the output (alone) is seamless.
You could set the timeScale to 0 so that Animation and FixedUpdate are not called.
As for the Update you would have to add some checks:
void Update()
{
if(Manager.cleaningTexture == true){ return; }
// Rest of the code
}
这篇关于Unity:如何暂停执行,直到函数终止,以便跳过任何帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!