暂停:
Time.timeScale = 0f;
恢复:
Time.timeScale = 1f;
截取开发文档中的描述:
The scale at which time passes. This can be used for slow motion
effects.When timeScale is 1.0 time passes as fast as realtime. When timeScale
is 0.5 time passes 2x slower than realtime.When timeScale is set to zero the game is basically paused if all your
functions are frame rate independent.
即Time.timeScale是用于控制时间流速,为0f时即停止,为1f时是与现实时间相同,在简单实现暂停与恢复功能时可以直接对其赋值0f或1f。
当然通过赋予其他值可实现不同时间流速,来达到特殊的动作效果,如慢放等。