Skip to content

Commit 9c41aca

Browse files
committed
修改获取下载路径的/问题
1 parent debfdf6 commit 9c41aca

3 files changed

Lines changed: 29 additions & 6 deletions

File tree

Assets/BundleMaster/BundleMasterRuntime/AssetComponentUpdate.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,15 +257,15 @@ private static async ETTask CalcNeedUpdateBundle(UpdateBundleDataInfo updateBund
257257
{
258258
if (crc != streamingCrc)
259259
{
260-
if (!File.Exists(Path.Combine(AssetComponentConfig.HotfixPath, bundlePackageName, info[0])))
260+
if (!File.Exists(PathUnifiedHelper.UnifiedPath(Path.Combine(AssetComponentConfig.HotfixPath, bundlePackageName, info[0]))))
261261
{
262262
needUpdateBundles.Add(info[0], long.Parse(info[1]));
263263
}
264264
}
265265
}
266266
else
267267
{
268-
if (!File.Exists(Path.Combine(AssetComponentConfig.HotfixPath, bundlePackageName, info[0])))
268+
if (!File.Exists(PathUnifiedHelper.UnifiedPath(Path.Combine(AssetComponentConfig.HotfixPath, bundlePackageName, info[0]))))
269269
{
270270
needUpdateBundles.Add(info[0], long.Parse(info[1]));
271271
}

Assets/BundleMaster/BundleMasterRuntime/DownLoadTask.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ public async ETTask DownLoad()
7171
Debug.Assert(downLoadData.Data != null, "downLoadData.Data != null");
7272
int dataLength = downLoadData.Data.Length;
7373

74-
string fileCreatePath = Path.Combine(DownLoadPackagePath, FileName);
75-
fileCreatePath = fileCreatePath.Replace("\\", "/");
74+
string fileCreatePath = PathUnifiedHelper.UnifiedPath(Path.Combine(DownLoadPackagePath, FileName));
7675
using (FileStream fs = new FileStream(fileCreatePath, FileMode.Create))
7776
{
7877
//大于2M用异步
@@ -128,8 +127,7 @@ public async ETTask ThreadDownLoad()
128127
url = Path.Combine(AssetComponentConfig.BundleServerUrl, PackegName, fileUrls);
129128
}
130129
//计算文件存储路径
131-
string fileCreatePath = Path.Combine(DownLoadPackagePath, FileName);
132-
fileCreatePath = fileCreatePath.Replace("\\", "/");
130+
string fileCreatePath = PathUnifiedHelper.UnifiedPath(Path.Combine(DownLoadPackagePath, FileName));
133131
//开始下载
134132
LmtDownloadInfo lmtDownloadInfo = await DownloadBundleHelper.DownloadData(url, fileCreatePath, UpdateBundleDataInfo);
135133
//说明下载更新已经被取消
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
namespace BM
2+
{
3+
public static class PathUnifiedHelper
4+
{
5+
/// <summary>
6+
/// 解决路径资源是否存在的判定问题
7+
/// </summary>
8+
public static string UnifiedPath(string path)
9+
{
10+
11+
#if UNITY_ANDROID && !UNITY_EDITOR
12+
path = path.Replace("\\", "/");
13+
#elif UNITY_IOS && !UNITY_EDITOR
14+
path = path.Replace("\\", "/");
15+
#elif UNITY_EDITOR_OSX || UNITY_STANDALONE_OSX
16+
17+
#elif UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
18+
19+
#endif
20+
return path;
21+
}
22+
23+
24+
}
25+
}

0 commit comments

Comments
 (0)