製作地下室地圖、Raw Input 整合後續修正
This commit is contained in:
1 parent
81d2a150c2
commit
23c311e905
191 files changed
+59056
-9911
No files matched your search
@@ -6,6 +6,7 @@ using UnityEngine.EventSystems;
|
||||
using UnityEngine.InputSystem.UI;
|
||||
|
||||
// 遊戲中按 Esc 暫停 : 時間停止、放開滑鼠,選「繼續」或「回到主畫面」
|
||||
// 切出遊戲視窗 (Alt+Tab 等) 時也會自動暫停
|
||||
// 暫停期間記錄器不記錄,回合照樣有效
|
||||
public class PauseMenu : MonoBehaviour
|
||||
{
|
||||
@@ -25,6 +26,9 @@ public class PauseMenu : MonoBehaviour
|
||||
// 給其他腳本判斷 (視角、記錄器)
|
||||
public static bool IsPaused { get; private set; }
|
||||
|
||||
// 開始暫停的時間 (跟記錄器同一條時間軸) : 切出視窗時遊戲會停住,記錄器要靠這個知道真正的暫停時間
|
||||
public static double PauseStartTime { get; private set; }
|
||||
|
||||
void Start()
|
||||
{
|
||||
EnsureButtonsClickable();
|
||||
@@ -43,6 +47,12 @@ public class PauseMenu : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
// 遊戲視窗失去焦點 (Alt+Tab、點到別的視窗) : 自動暫停,回來時要按「繼續」
|
||||
void OnApplicationFocus(bool hasFocus)
|
||||
{
|
||||
if (!hasFocus && !IsPaused) Pause();
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
// 離開場景時一定要恢復,不然下一個場景會停住
|
||||
@@ -71,6 +81,7 @@ public class PauseMenu : MonoBehaviour
|
||||
void Pause()
|
||||
{
|
||||
IsPaused = true;
|
||||
PauseStartTime = Time.realtimeSinceStartupAsDouble;
|
||||
Time.timeScale = 0f;
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
Cursor.visible = true;
|
||||
|
||||
Reference in new issue
Block a user