From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Scripts/XUtliPoolLib/AssetBundleLoader.cs | 92 ++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 Client/Assets/Scripts/XUtliPoolLib/AssetBundleLoader.cs (limited to 'Client/Assets/Scripts/XUtliPoolLib/AssetBundleLoader.cs') diff --git a/Client/Assets/Scripts/XUtliPoolLib/AssetBundleLoader.cs b/Client/Assets/Scripts/XUtliPoolLib/AssetBundleLoader.cs new file mode 100644 index 00000000..e9ab225c --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/AssetBundleLoader.cs @@ -0,0 +1,92 @@ +using System; +using UnityEngine; +using XUpdater; + +namespace XUtliPoolLib +{ + public abstract class AssetBundleLoader + { + public virtual bool isComplete + { + get + { + return this.state == LoadState.State_Error || this.state == LoadState.State_Complete; + } + } + + internal AssetBundleManager.LoadAssetCompleteHandler onComplete; + + public int loadHandlerID; + + public uint bundleName; + + public AssetBundleData bundleData; + + public AssetBundleInfo bundleInfo; + + public AssetBundleManager bundleManager; + + public LoadState state = LoadState.State_None; + + protected AssetBundleLoader[] depLoaders; + + public virtual void Load() + { + } + + public virtual void LoadImm() + { + } + + public virtual void LoadBundle() + { + } + + public virtual void LoadBundleImm() + { + } + + protected virtual void Complete() + { + bool flag = this.onComplete != null; + if (flag) + { + AssetBundleManager.LoadAssetCompleteHandler loadAssetCompleteHandler = this.onComplete; + this.onComplete = null; + loadAssetCompleteHandler(this.bundleInfo, this.loadHandlerID); + } + this.bundleManager.LoadComplete(this); + } + + protected virtual void Error() + { + bool flag = this.onComplete != null; + if (flag) + { + AssetBundleManager.LoadAssetCompleteHandler loadAssetCompleteHandler = this.onComplete; + this.onComplete = null; + loadAssetCompleteHandler(this.bundleInfo, this.loadHandlerID); + } + this.bundleManager.LoadError(this); + } + + protected bool UnloadNotLoadingBundle(AssetBundle bundle) + { + bool flag = bundle == null; + bool result; + if (flag) + { + int bundleCount = XSingleton.singleton.ABManager.BundleCount; + XSingleton.singleton.ABManager.UnloadNotUsedLoader(); + Resources.UnloadUnusedAssets(); + XSingleton.singleton.AddErrorLog("AssetBundle Count: ", bundleCount.ToString(), " , ", XSingleton.singleton.ABManager.BundleCount.ToString(), null, null); + result = true; + } + else + { + result = false; + } + return result; + } + } +} -- cgit v1.1-26-g67d0