unity3d 怎么做游戏暂停弹窗
2个回答
展开全部
Time.timeScale = value;value 为0时,游戏就暂停了,为1时就是正常速度。但是实例化的对象不会暂停在官方脚本中有解释 Time.timeScale = 0;Time.timeScale 的确是能暂停一些东西。但是如果在update函数中持续改变一个物体的位置,这种位置改变貌似是不会受到暂停影响的。
transform.position = transform.position+transform.TransformDirection(Vector3(0,0,throwForce));
Time.timeScale = 0的时候这个东西仍然在动~~~~~
Time.timeScale
Time.timeScale
The scale at which the time is passing. This can be used for slow motion effects.
When timeScale is 1.0 the time is passing as fast as realtime. When timeScale is 0.5 the time is passing 2x slower than realtime.
When timeScale is set to zero the game is basically paused if all your functions are frame rate independent.
Except for realtimeSinceStartup, timeScale affects all the time and delta time measuring variables of the Time class.
If you lower timeScale it is recommended to also lower Time.fixedDeltaTime by the same amount.
FixedUpdate functions will not be called when timeScale is set to zero.
---------------------------------------------------------------------
可以试试FixedUpdate()
你们说的那种情况我暂时还没遇到过。
----------------------------------------------------------------------
在Unity Answer上看到有人用这样的方法:
When the game needs to pause, call the OnPauseGame function on all objects using something like this:
Object[] objects = FindObjectsOfType (typeof(GameObject));
foreach (GameObject go in objects) {
go.SendMessage ("OnPauseGame", SendMessageOptions.DontRequireReceiver);
}
And to resume call OnResumeGame on all objects.
A basic script with movement in the Update() could have something like this:
protected bool paused;
void OnPauseGame ()
{
paused = true;
}
void OnResumeGame ()
{
paused = false;
}
void Update ()
{
if (!paused) {
// do movement
}
}
transform.position = transform.position+transform.TransformDirection(Vector3(0,0,throwForce));
Time.timeScale = 0的时候这个东西仍然在动~~~~~
Time.timeScale
Time.timeScale
The scale at which the time is passing. This can be used for slow motion effects.
When timeScale is 1.0 the time is passing as fast as realtime. When timeScale is 0.5 the time is passing 2x slower than realtime.
When timeScale is set to zero the game is basically paused if all your functions are frame rate independent.
Except for realtimeSinceStartup, timeScale affects all the time and delta time measuring variables of the Time class.
If you lower timeScale it is recommended to also lower Time.fixedDeltaTime by the same amount.
FixedUpdate functions will not be called when timeScale is set to zero.
---------------------------------------------------------------------
可以试试FixedUpdate()
你们说的那种情况我暂时还没遇到过。
----------------------------------------------------------------------
在Unity Answer上看到有人用这样的方法:
When the game needs to pause, call the OnPauseGame function on all objects using something like this:
Object[] objects = FindObjectsOfType (typeof(GameObject));
foreach (GameObject go in objects) {
go.SendMessage ("OnPauseGame", SendMessageOptions.DontRequireReceiver);
}
And to resume call OnResumeGame on all objects.
A basic script with movement in the Update() could have something like this:
protected bool paused;
void OnPauseGame ()
{
paused = true;
}
void OnResumeGame ()
{
paused = false;
}
void Update ()
{
if (!paused) {
// do movement
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询