From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../XUtliPoolLib/AssetBundlePathResolver.cs | 215 +++++++++++++++++++++ 1 file changed, 215 insertions(+) create mode 100644 Client/Assets/Scripts/XUtliPoolLib/AssetBundlePathResolver.cs (limited to 'Client/Assets/Scripts/XUtliPoolLib/AssetBundlePathResolver.cs') diff --git a/Client/Assets/Scripts/XUtliPoolLib/AssetBundlePathResolver.cs b/Client/Assets/Scripts/XUtliPoolLib/AssetBundlePathResolver.cs new file mode 100644 index 00000000..6235c1b4 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/AssetBundlePathResolver.cs @@ -0,0 +1,215 @@ +using System; +using System.IO; +using System.Text; +using UnityEngine; +using XUpdater; + +namespace XUtliPoolLib +{ + public class AssetBundlePathResolver + { + public virtual string BundleSaveDirName + { + get + { + return "AssetBundles"; + } + } + + public string AndroidBundleSavePath + { + get + { + return "Assets/StreamingAssets/update/Android/" + this.BundleSaveDirName; + } + } + + public string iOSBundleSavePath + { + get + { + return "Assets/StreamingAssets/update/iOS/" + this.BundleSaveDirName; + } + } + + public string DefaultBundleSavePath + { + get + { + return "Assets/StreamingAssets/update/" + this.BundleSaveDirName; + } + } + + public virtual string AndroidHashCacheSaveFile + { + get + { + return "Assets/AssetBundles/Android/cache.txt"; + } + } + + public virtual string iOSHashCacheSaveFile + { + get + { + return "Assets/AssetBundles/iOS/cache.txt"; + } + } + + public virtual string DefaultHashCacheSaveFile + { + get + { + return "Assets/AssetBundles/cache.txt"; + } + } + + public virtual string DependFileName + { + get + { + return "dep.all"; + } + } + + public virtual string BundleCacheDir + { + get + { + bool flag = this.cacheDir == null; + if (flag) + { + RuntimePlatform platform = Application.platform; + string path; + if ((int)platform != 8) + { + if ((int)platform != 11) + { + XPlatformType xplatformType = XSingleton.singleton.XPlatform.Platfrom(); + XPlatformType xplatformType2 = xplatformType; + if (xplatformType2 != XPlatformType.IOS) + { + if (xplatformType2 != XPlatformType.Android) + { + path = string.Format("{0}/update/AssetBundles", Application.streamingAssetsPath); + } + else + { + path = string.Format("{0}/update/Android/AssetBundles", Application.streamingAssetsPath); + } + } + else + { + path = string.Format("{0}/update/iOS/AssetBundles", Application.streamingAssetsPath); + } + } + else + { + path = string.Format("{0}/update/AssetBundles", Application.persistentDataPath); + } + } + else + { + path = string.Format("{0}/update/AssetBundles", Application.persistentDataPath); + } + this.cacheDir = new DirectoryInfo(path); + bool flag2 = !this.cacheDir.Exists; + if (flag2) + { + this.cacheDir.Create(); + } + } + return this.cacheDir.FullName; + } + } + + public static AssetBundlePathResolver instance; + + private string cachePath = null; + + private string cachePathWWW = null; + + private StringBuilder pathSB = new StringBuilder(); + + private DirectoryInfo cacheDir; + + public AssetBundlePathResolver() + { + AssetBundlePathResolver.instance = this; + } + + public virtual string GetEditorModePath(string abName) + { + abName = abName.Replace(".", "/"); + int num = abName.LastIndexOf("/"); + bool flag = num == -1; + string result; + if (flag) + { + result = abName; + } + else + { + string text = string.Format("{0}.{1}", abName.Substring(0, num), abName.Substring(num + 1)); + result = text; + } + return result; + } + + public virtual string GetBundleSourceFile(string path, bool forWWW = true) + { + if (forWWW) + { + bool flag = this.cachePathWWW == null; + if (flag) + { + RuntimePlatform platform = Application.platform; + if ((int)platform != 8) + { + if ((int)platform != 11) + { + this.cachePathWWW = string.Format("file://{0}/StreamingAssets/update/{1}/", Application.dataPath, this.BundleSaveDirName); + } + else + { + this.cachePathWWW = string.Format("jar:file://{0}!/assets/update/Android/{1}/", Application.dataPath, this.BundleSaveDirName); + } + } + else + { + this.cachePathWWW = string.Format("file://{0}/Raw/update/iOS/{1}/", Application.dataPath, this.BundleSaveDirName); + } + } + this.pathSB.Length = 0; + this.pathSB.Append(this.cachePathWWW); + } + else + { + bool flag2 = this.cachePath == null; + if (flag2) + { + RuntimePlatform platform2 = Application.platform; + if ((int)platform2 != 8) + { + if ((int)platform2 != 11) + { + this.cachePath = string.Format("{0}/StreamingAssets/update/{1}/", Application.dataPath, this.BundleSaveDirName); + } + else + { + this.cachePath = string.Format("{0}!assets/update/Android/{1}/", Application.dataPath, this.BundleSaveDirName); + } + } + else + { + this.cachePath = string.Format("{0}/Raw/update/iOS/{1}/", Application.dataPath, this.BundleSaveDirName); + } + } + this.pathSB.Length = 0; + this.pathSB.Append(this.cachePath); + } + this.pathSB.Append(path); + return this.pathSB.ToString(); + } + } +} -- cgit v1.1-26-g67d0