Ver.0.3.0.33

This commit is contained in:
2025-07-08 08:32:46 +00:00
parent 99f4dd67c2
commit 0ad5e29917
6831 changed files with 695623 additions and 234455 deletions
+34 -17
View File
@@ -1,34 +1,28 @@
using System;
using System.Collections;
using AibisDream.Framework;
using AibisDream.Kit;
using AibisDream.FixSystem;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;
using DG.Tweening;
namespace AibisDream
{
public class SceneLoader : Singleton<SceneLoader>
{
#region
private BindProperty<string> _currentScene;
private AsyncOperationHandle _loadHandle;
private string _sceneToLoad;
private bool _isLoading;
private readonly SceneData _data = new();
public override void OnSingletonInit()
{
_currentScene = new BindProperty<string>();
}
private void Start()
{
_currentScene.Register(GameLoopManager.Instance.UpdateCurScene);
}
private void OnDisable()
{
_currentScene.RemoveAll();
StorageSystem.Instance.RegisterData(_data);
}
#endregion
@@ -58,8 +52,19 @@ namespace AibisDream
// 场景转换参数
_isLoading = true;
_sceneToLoad = targetScene;
if (!string.IsNullOrEmpty(_currentScene.Value))
// 在卸载场景前清理所有系统
if (!string.IsNullOrEmpty(_data.sceneName))
{
// 清理所有DOTween动画
DOTween.KillAll();
// 清理所有系统注册
if (FixSystemCenter.SystemDic != null)
{
FixSystemCenter.SystemDic.Clear();
}
yield return Addressables.UnloadSceneAsync(_loadHandle);
}
@@ -67,7 +72,7 @@ namespace AibisDream
yield return _loadHandle;
EnumEventSystem.Global.Send(EventEnum.SceneLoad, _sceneToLoad);
_currentScene.Value = _sceneToLoad;
_data.sceneName = _sceneToLoad;
_isLoading = false;
}
}
@@ -85,12 +90,24 @@ namespace AibisDream
if (_loadHandle.IsValid())
{
yield return Addressables.UnloadSceneAsync(_loadHandle);
_currentScene.Value = null;
EnumEventSystem.Global.Send(EventEnum.SceneUnload);
_data.sceneName = null;
}
_isLoading = false;
}
}
}
[Serializable]
[LoadIndex(1)]
public class SceneData : IData
{
public string sceneName;
public IEnumerator Load()
{
// yield return UIManager.Instance.GetPanel<PlayToolPanel>().FadeInAsync();
yield return SceneLoader.Instance.LoadSceneAsync(sceneName);
}
}
}