每当我暂停时,一切都会停止,这就是我想要的样子,但唯一不会停止的就是相机。我移动我的光标,相机仍然跟随。我想让它冻结。我正在使用资产存储中的FPS控制器资产
using System.Collections;
using System.Collections.Generic;
using UnityStandardAssets.Characters.FirstPerson;
using UnityEngine;
using UnityEngine.SceneManagement;
public class PauseMenu : MonoBehaviour
{
public static bool GameIsPaused = false;
static bool IsPaused = false;
public GameObject pauseMenuUI;
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
if (GameIsPaused)
{
Resume();
} else
{
Pause();
}
}
}
public void Resume()
{
pauseMenuUI.SetActive(false);
Time.timeScale = 1f;
AudioListener.pause = false;
GameIsPaused = false;
}
void Pause()
{
pauseMenuUI.SetActive(true);
Time.timeScale = 0f;
AudioListener.pause = true;
GameIsPaused = true;
}
public void LoadMenu()
{
Time.timeScale = 1f;
SceneManager.LoadScene("Menu");
}
public void QuitGame()
{
Debug.Log("Exiting Game");
Application.Quit();
}
}
发布于 2019-05-10 04:04:42
获取对Character Controller脚本的引用,然后禁用它:
mycharfpscon.enabled = false;
然后重新启用它:
mycharfpscon.enabled = true;
https://stackoverflow.com/questions/56066708
复制相似问题