diff options
author | chai <chaifix@163.com> | 2021-01-25 14:28:30 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-01-25 14:28:30 +0800 |
commit | 6eb915c129fc90c6f4c82ae097dd6ffad5239efc (patch) | |
tree | 7dd2be50edf41f36b60fac84696e731c13afe617 /Client/Assets/Scripts/XUtliPoolLib/AssetBundlePathResolver.cs |
+scripts
Diffstat (limited to 'Client/Assets/Scripts/XUtliPoolLib/AssetBundlePathResolver.cs')
-rw-r--r-- | Client/Assets/Scripts/XUtliPoolLib/AssetBundlePathResolver.cs | 215 |
1 files changed, 215 insertions, 0 deletions
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<XUpdater.XUpdater>.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();
+ }
+ }
+}
|