存储功能更新

This commit is contained in:
2025-03-25 23:14:01 +08:00
parent cbe042fec1
commit 7f5c17dff8
16 changed files with 209 additions and 651 deletions
+20 -16
View File
@@ -1,3 +1,4 @@
using System;
using System.Collections;
using AibisDream.Framework;
using AibisDream.Kit;
@@ -10,25 +11,16 @@ 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,7 +50,7 @@ namespace AibisDream
// 场景转换参数
_isLoading = true;
_sceneToLoad = targetScene;
if (!string.IsNullOrEmpty(_currentScene.Value))
if (!string.IsNullOrEmpty(_data.sceneName))
{
yield return Addressables.UnloadSceneAsync(_loadHandle);
}
@@ -67,7 +59,7 @@ namespace AibisDream
yield return _loadHandle;
EnumEventSystem.Global.Send(EventEnum.SceneLoad, _sceneToLoad);
_currentScene.Value = _sceneToLoad;
_data.sceneName = _sceneToLoad;
_isLoading = false;
}
}
@@ -85,7 +77,7 @@ namespace AibisDream
if (_loadHandle.IsValid())
{
yield return Addressables.UnloadSceneAsync(_loadHandle);
_currentScene.Value = null;
_data.sceneName = null;
EnumEventSystem.Global.Send(EventEnum.SceneUnload);
}
@@ -93,4 +85,16 @@ namespace AibisDream
}
}
}
[Serializable]
[LoadIndex(0)]
public class SceneData : IData
{
public string sceneName;
public IEnumerator Load()
{
yield return SceneLoader.Instance.LoadSceneAsync(sceneName);
}
}
}