From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Scripts/XUtliPoolLib/XUpdater/XBundle.cs | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XUpdater/XBundle.cs (limited to 'Client/Assets/Scripts/XUtliPoolLib/XUpdater/XBundle.cs') diff --git a/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XBundle.cs b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XBundle.cs new file mode 100644 index 00000000..acb8fa42 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XUpdater/XBundle.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections; +using UnityEngine; + +namespace XUpdater +{ + internal sealed class XBundle : MonoBehaviour + { + private AssetBundleRequest _assetloader = null; + + public void GetBundle(WWW www, byte[] data, HandleLoadBundle callback, bool load) + { + base.StartCoroutine(this.LoadBundle(www, data, callback, load)); + } + + public void GetAsset(AssetBundle bundle, XResPackage package, HandleLoadAsset callback) + { + base.StartCoroutine(this.LoadAsset(bundle, package, callback)); + } + + private IEnumerator LoadBundle(WWW www, byte[] data, HandleLoadBundle callback, bool load) + { + AssetBundle bundle = null; + if (load) + { + bool flag = www != null; + if (flag) + { + bundle = www.assetBundle; + } + else + { + bundle = AssetBundle.LoadFromMemory(data); + } + yield return null; + } + bool flag2 = callback != null; + if (flag2) + { + callback(bundle); + } + bool flag3 = www != null; + if (flag3) + { + www.Dispose(); + } + www = null; + yield break; + } + + private IEnumerator LoadAsset(AssetBundle bundle, XResPackage package, HandleLoadAsset callback) + { + this._assetloader = bundle.LoadAssetAsync(base.name, XUpdater.Ass.GetType(package.type)); + yield return this._assetloader; + bool flag = callback != null; + if (flag) + { + callback(package, this._assetloader.asset); + } + this._assetloader = null; + yield break; + } + } +} -- cgit v1.1-26-g67d0