unity3d 怎么做游戏暂停弹窗
答案:2 悬赏:0 手机版
解决时间 2021-02-16 14:02
- 提问者网友:饥饿走向夜
- 2021-02-15 16:42
就是点一下暂停按钮,然后弹出个暂停窗口。最好是用C#的代码,不是也行,谢谢!
最佳答案
- 五星知识达人网友:患得患失的劫
- 2021-02-15 18:19
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
}
}
全部回答
- 1楼网友:舍身薄凉客
- 2021-02-15 19:07
简单点来说,控制Time.timeScale=0就让时间静止了,此时你写一个GUI弹出来即可
复杂的话,你需要设置一个暂停系统,控制各种可以动的对象,通过发送bool而使他们运动和停止
希望对你有帮助,望采纳
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯