优化死亡界面跳转
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace GameFramework
|
||||
{
|
||||
@@ -39,6 +40,23 @@ namespace GameFramework
|
||||
|
||||
private bool _isVisible;
|
||||
|
||||
/// <summary>
|
||||
/// 运行时初始化所有引用(由 GameManager 自动创建时调用)。
|
||||
/// </summary>
|
||||
public void Initialize(Canvas canvas, GameObject win, Button winBtn, Text winTitle, Text winScore,
|
||||
GameObject lose, Button loseBtn, Text loseTitle, Text loseScore)
|
||||
{
|
||||
resultCanvas = canvas;
|
||||
winPanel = win;
|
||||
winConfirmButton = winBtn;
|
||||
winTitleText = winTitle;
|
||||
winScoreText = winScore;
|
||||
losePanel = lose;
|
||||
loseConfirmButton = loseBtn;
|
||||
loseTitleText = loseTitle;
|
||||
loseScoreText = loseScore;
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
GameManager.onGameOver += OnGameOver;
|
||||
@@ -108,7 +126,14 @@ namespace GameFramework
|
||||
|
||||
// 暂停游戏
|
||||
if (TimeController.Instance != null)
|
||||
{
|
||||
TimeController.Instance.Pause();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 没有 TimeController 时直接设置 timeScale
|
||||
Time.timeScale = 0f;
|
||||
}
|
||||
|
||||
// 显示鼠标
|
||||
Cursor.visible = true;
|
||||
@@ -132,11 +157,24 @@ namespace GameFramework
|
||||
|
||||
// 解除暂停
|
||||
if (TimeController.Instance != null)
|
||||
{
|
||||
TimeController.Instance.Unpause();
|
||||
}
|
||||
else
|
||||
{
|
||||
Time.timeScale = 1f;
|
||||
}
|
||||
|
||||
// 跳转到排行榜
|
||||
if (SceneLoader.Instance != null)
|
||||
{
|
||||
SceneLoader.Instance.LoadScoringScene();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 没有 SceneLoader 时直接加载场景
|
||||
SceneManager.LoadScene("Scoring");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user