feat(Cycle):实现循环提前检测,修复交互提示消失,按键绑定的事件在重启的时候没能正确,触发循环的提前检测有错误

This commit is contained in:
2025-10-27 10:31:01 +08:00
parent e8b9f47067
commit 9646483fa6
36 changed files with 6743 additions and 5221 deletions

View File

@@ -1,88 +0,0 @@
using UnityEngine;
using UnityEngine.SceneManagement;
using System.Collections;
namespace Core
{
public class ScenesManager : MonoSingleton<ScenesManager>
{
private string currentGameplayScene;
private bool isLoadGameplayUI = false;
// 修正:直接根据当前激活场景判断
public bool IsInMainMenu =>
currentGameplayScene == "StartMenu";
// 修正:只有当已有记录的 gameplay 场景且激活场景与之匹配时才返回 true
public bool IsInGameplay =>
currentGameplayScene == "Level1" || currentGameplayScene == "Test";
public bool IsActiveScene(string sceneName)
{
return SceneManager.GetActiveScene().name == sceneName;
}
public bool IsSceneLoaded(string sceneName)
{
return SceneManager.GetSceneByName(sceneName).isLoaded;
}
public void LoadMainMenu()
{
if (isLoadGameplayUI)
{
StartCoroutine(UnloadScene("UIScene"));
isLoadGameplayUI = false;
}
StartCoroutine(SwitchGameplay("StartMenu"));
}
public void LoadGameplay(string sceneName)
{
StartCoroutine(SwitchGameplay(sceneName));
ReLoadUIScene();
}
public void ReLoadUIScene()
{
if (isLoadGameplayUI)
{
StartCoroutine(UnloadScene("UIScene"));
}
StartCoroutine(LoadSceneAdditive("UIScene"));
isLoadGameplayUI = true;
}
private IEnumerator SwitchGameplay(string newScene)
{
if (!string.IsNullOrEmpty(currentGameplayScene))
{
yield return UnloadScene(currentGameplayScene);
}
yield return LoadSceneAdditive(newScene);
currentGameplayScene = newScene;
// 可选:将新场景设置为激活场景
SceneManager.SetActiveScene(SceneManager.GetSceneByName(newScene));
}
private IEnumerator LoadSceneAdditive(string sceneName)
{
var async = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);
while (!async.isDone)
{
yield return null;
}
}
private IEnumerator UnloadScene(string sceneName)
{
var async = SceneManager.UnloadSceneAsync(sceneName);
while (!async.isDone)
{
yield return null;
}
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 9f0b4ab0cd384d91bfb99fd97c34ac5d
timeCreated: 1760401308