using XGame.Framework.Asyncs; namespace XGame.Framework.Asset { internal class SceneLoadAsync : Async, IAssetAsync { public string AddressableName { get; internal set; } /// /// async的Start标记 /// private bool isStart; /// /// asyncGroup完成标记 /// private bool groupCompleted; /// /// scene所依赖的bundle的AsyncGroup /// private AsyncGroup bundleAsyncGroup; internal AsyncGroup BundleAsyncGroup { get => bundleAsyncGroup; set { bundleAsyncGroup = value; bundleAsyncGroup?.On(OnGroupCompleted); } } public int AssetHash { get; set; } public override float Progress { get { float progress = bundleAsyncGroup?.Progress ?? 0; return progress / 2; } protected set => base.Progress = value; } public object GetResult() { return null; } public void Start() { isStart = true; if(bundleAsyncGroup == null || groupCompleted) { Completed(); } } private void OnGroupCompleted(IAsync async) { groupCompleted = true; if (isStart) { Completed(); } } private void Clear() { isStart = false; groupCompleted = false; bundleAsyncGroup = null; } } }