Skip to content

Commit

Permalink
[fix][runtime]:uwr访问本地文件路径统一加file头
Browse files Browse the repository at this point in the history
  • Loading branch information
CatImmortal committed Nov 1, 2023
1 parent a751c0f commit 398f9ba
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public string LoadPath
switch (BundleState)
{
case State.InReadOnly:
loadPath = RuntimeUtil.GetReadOnlyPath(Manifest.RelativePath);
loadPath = RuntimeUtil.GetReadOnlyPath(Manifest.RelativePath,Manifest.IsRaw);
break;
case State.InReadWrite:
case State.InRemote:
Expand Down
2 changes: 1 addition & 1 deletion Assets/CatAsset/Runtime/Loader/PackageOnlyAssetLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class PackageOnlyAssetLoader : DefaultAssetLoader
/// <inheritdoc />
public override void CheckVersion(OnVersionChecked onVersionChecked)
{
string path = RuntimeUtil.GetReadOnlyPath(CatAssetManifest.ManifestBinaryFileName);
string path = RuntimeUtil.GetReadOnlyPath(CatAssetManifest.ManifestBinaryFileName,true);

CatAssetManager.AddWebRequestTask(path,path,((success, uwr) =>
{
Expand Down
11 changes: 9 additions & 2 deletions Assets/CatAsset/Runtime/Misc/RuntimeUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,16 @@ public static string GetRegularPath(string path)
/// <summary>
/// 获取在只读区下的完整路径
/// </summary>
public static string GetReadOnlyPath(string path)
public static string GetReadOnlyPath(string path,bool isUwrPath = false)
{
string result = GetRegularPath(Path.Combine(Application.streamingAssetsPath, path));

if (isUwrPath && !path.Contains("file://"))
{
//使用UnityWebRequest访问 统一加file://头
result = "file://" + result;
}

return result;
}

Expand All @@ -53,7 +60,7 @@ public static string GetReadWritePath(string path,bool isUwrPath = false)

if (isUwrPath && !path.Contains("file://"))
{
//使用UnityWebRequest访问Persistent路径 统一加file://头
//使用UnityWebRequest访问 统一加file://头
result = "file://" + result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static void CheckVersion(OnVersionChecked callback)
onVersionChecked = callback;

//进行只读区 读写区 远端三方的资源清单检查
string readOnlyManifestPath = RuntimeUtil.GetReadOnlyPath(CatAssetManifest.ManifestBinaryFileName);
string readOnlyManifestPath = RuntimeUtil.GetReadOnlyPath(CatAssetManifest.ManifestBinaryFileName,true);
string readWriteManifestPath = RuntimeUtil.GetReadWritePath(CatAssetManifest.ManifestBinaryFileName, true);
string remoteManifestPath = RuntimeUtil.GetRemotePath(CatAssetManifest.ManifestBinaryFileName);

Expand Down

0 comments on commit 398f9ba

Please sign in to comment.