提交
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Collections;
|
||||
using AibisDream.Framework;
|
||||
using AibisDream.Kit;
|
||||
using UnityEditor;
|
||||
using UnityEngine.AddressableAssets;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
using UnityEngine.SceneManagement;
|
||||
@@ -90,5 +91,43 @@ namespace AibisDream
|
||||
_isLoading = false;
|
||||
}
|
||||
}
|
||||
#region 重新开始游戏功能
|
||||
|
||||
/// <summary>
|
||||
/// 重新开始游戏,重新加载当前场景
|
||||
/// </summary>
|
||||
public void RestartGame()
|
||||
{
|
||||
// 确保场景正在加载或卸载前,先重置相关状态
|
||||
StartCoroutine(RestartGameCoroutine());
|
||||
}
|
||||
|
||||
private IEnumerator RestartGameCoroutine()
|
||||
{
|
||||
if (_isLoading)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 清除当前场景的状态(如果需要)
|
||||
_isLoading = true;
|
||||
|
||||
if (!string.IsNullOrEmpty(_currentScene.Value))
|
||||
{
|
||||
// 卸载当前场景
|
||||
yield return Addressables.UnloadSceneAsync(_loadHandle);
|
||||
}
|
||||
yield return MainUIController.Instance.FadeInSync(1);
|
||||
DialogController.Instance.StopDialog();
|
||||
yield return MainUIController.Instance.TVFadeInSync(1);
|
||||
MainUIController.Instance.ShowMainUI();
|
||||
StartMenu.Instance.showStartMenu();
|
||||
yield return MainUIController.Instance.FadeOutSync(1);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user