update runtime code

重构了PersistentTools类
pull/134/head
hevinci 2023-07-05 15:14:21 +08:00
parent c5314c72f0
commit 2643ab81ed
15 changed files with 246 additions and 216 deletions

View File

@ -45,7 +45,7 @@ namespace YooAsset
{ {
// BundleFiles // BundleFiles
{ {
string rootPath = PersistentTools.GetCachedBundleFileFolderPath(_packageName); string rootPath = PersistentTools.GetPersistent(_packageName).SandboxCacheBundleFilesRoot;
DirectoryInfo rootDirectory = new DirectoryInfo(rootPath); DirectoryInfo rootDirectory = new DirectoryInfo(rootPath);
if (rootDirectory.Exists) if (rootDirectory.Exists)
{ {
@ -56,7 +56,7 @@ namespace YooAsset
// RawFiles // RawFiles
{ {
string rootPath = PersistentTools.GetCachedRawFileFolderPath(_packageName); string rootPath = PersistentTools.GetPersistent(_packageName).SandboxCacheRawFilesRoot;
DirectoryInfo rootDirectory = new DirectoryInfo(rootPath); DirectoryInfo rootDirectory = new DirectoryInfo(rootPath);
if (rootDirectory.Exists) if (rootDirectory.Exists)
{ {

View File

@ -0,0 +1,163 @@
using System.IO;
namespace YooAsset
{
internal class Persistent
{
private readonly string _packageName;
public string BuildinRoot { private set; get; }
public string BuildinPackageRoot { private set; get; }
public string SandboxRoot { private set; get; }
public string SandboxPackageRoot { private set; get; }
public string SandboxCacheBundleFilesRoot { private set; get; }
public string SandboxCacheRawFilesRoot { private set; get; }
public string SandboxManifestFilesRoot { private set; get; }
public string SandboxAppFootPrintFilePath { private set; get; }
public Persistent(string packageName)
{
_packageName = packageName;
}
/// <summary>
/// 重写根路径
/// </summary>
public void OverwriteRootDirectory(string buildinRoot, string sandboxRoot)
{
if (string.IsNullOrEmpty(buildinRoot))
BuildinRoot = CreateDefaultBuildinRoot();
else
BuildinRoot = buildinRoot;
if (string.IsNullOrEmpty(sandboxRoot))
SandboxRoot = CreateDefaultSandboxRoot();
else
SandboxRoot = sandboxRoot;
BuildinPackageRoot = PathUtility.Combine(BuildinRoot, _packageName);
SandboxPackageRoot = PathUtility.Combine(SandboxRoot, _packageName);
SandboxCacheBundleFilesRoot = PathUtility.Combine(SandboxPackageRoot, YooAssetSettings.CachedBundleFileFolder);
SandboxCacheRawFilesRoot = PathUtility.Combine(SandboxPackageRoot, YooAssetSettings.CachedRawFileFolder);
SandboxManifestFilesRoot = PathUtility.Combine(SandboxPackageRoot, YooAssetSettings.ManifestFolderName);
SandboxAppFootPrintFilePath = PathUtility.Combine(SandboxPackageRoot, YooAssetSettings.AppFootPrintFileName);
}
private static string CreateDefaultBuildinRoot()
{
return PathUtility.Combine(UnityEngine.Application.streamingAssetsPath, YooAssetSettings.DefaultYooFolderName);
}
private static string CreateDefaultSandboxRoot()
{
#if UNITY_EDITOR
// 注意:为了方便调试查看,编辑器下把存储目录放到项目里。
string projectPath = Path.GetDirectoryName(UnityEngine.Application.dataPath);
projectPath = PathUtility.RegularPath(projectPath);
return PathUtility.Combine(projectPath, YooAssetSettings.DefaultYooFolderName);
#elif UNITY_STANDALONE
return PathUtility.Combine(UnityEngine.Application.dataPath, YooAssetSettings.DefaultYooFolderName);
#else
return PathUtility.Combine(UnityEngine.Application.persistentDataPath, YooAssetSettings.DefaultYooFolderName);
#endif
}
/// <summary>
/// 删除沙盒里的包裹目录
/// </summary>
public void DeleteSandboxPackageFolder()
{
if (Directory.Exists(SandboxPackageRoot))
Directory.Delete(SandboxPackageRoot, true);
}
/// <summary>
/// 删除沙盒内的缓存文件夹
/// </summary>
public void DeleteSandboxCacheFilesFolder()
{
// CacheBundleFiles
if (Directory.Exists(SandboxCacheBundleFilesRoot))
Directory.Delete(SandboxCacheBundleFilesRoot, true);
// CacheRawFiles
if (Directory.Exists(SandboxCacheRawFilesRoot))
Directory.Delete(SandboxCacheRawFilesRoot, true);
}
/// <summary>
/// 删除沙盒内的清单文件夹
/// </summary>
public void DeleteSandboxManifestFilesFolder()
{
if (Directory.Exists(SandboxManifestFilesRoot))
Directory.Delete(SandboxManifestFilesRoot, true);
}
/// <summary>
/// 获取沙盒内包裹的清单文件的路径
/// </summary>
public string GetSandboxPackageManifestFilePath(string packageVersion)
{
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_packageName, packageVersion);
return PathUtility.Combine(SandboxManifestFilesRoot, fileName);
}
/// <summary>
/// 获取沙盒内包裹的哈希文件的路径
/// </summary>
public string GetSandboxPackageHashFilePath(string packageVersion)
{
string fileName = YooAssetSettingsData.GetPackageHashFileName(_packageName, packageVersion);
return PathUtility.Combine(SandboxManifestFilesRoot, fileName);
}
/// <summary>
/// 获取沙盒内包裹的版本文件的路径
/// </summary>
public string GetSandboxPackageVersionFilePath()
{
string fileName = YooAssetSettingsData.GetPackageVersionFileName(_packageName);
return PathUtility.Combine(SandboxManifestFilesRoot, fileName);
}
/// <summary>
/// 保存沙盒内默认的包裹版本
/// </summary>
public void SaveSandboxPackageVersionFile(string version)
{
string filePath = GetSandboxPackageVersionFilePath();
FileUtility.WriteAllText(filePath, version);
}
/// <summary>
/// 获取APP内包裹的清单文件的路径
/// </summary>
public string GetBuildinPackageManifestFilePath(string packageVersion)
{
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_packageName, packageVersion);
return PathUtility.Combine(BuildinPackageRoot, fileName);
}
/// <summary>
/// 获取APP内包裹的哈希文件的路径
/// </summary>
public string GetBuildinPackageHashFilePath(string packageVersion)
{
string fileName = YooAssetSettingsData.GetPackageHashFileName(_packageName, packageVersion);
return PathUtility.Combine(BuildinPackageRoot, fileName);
}
/// <summary>
/// 获取APP内包裹的版本文件的路径
/// </summary>
public string GetBuildinPackageVersionFilePath()
{
string fileName = YooAssetSettingsData.GetPackageVersionFileName(_packageName);
return PathUtility.Combine(BuildinPackageRoot, fileName);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 62ee5fd2821fe85488efff3f8242b703
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -3,92 +3,31 @@ using System.Collections.Generic;
namespace YooAsset namespace YooAsset
{ {
internal static class PersistentTools internal class PersistentTools
{ {
private const string SandboxFolderName = "Sandbox"; private static readonly Dictionary<string, Persistent> _persitentDic = new Dictionary<string, Persistent>(100);
private const string CacheFolderName = "CacheFiles";
private const string CachedBundleFileFolder = "BundleFiles";
private const string CachedRawFileFolder = "RawFiles";
private const string ManifestFolderName = "ManifestFiles";
private const string AppFootPrintFileName = "ApplicationFootPrint.bytes";
private static string _buildinPath;
private static string _sandboxPath;
/// <summary> /// <summary>
/// 重写内置跟路径 /// 获取包裹的持久化类
/// </summary> /// </summary>
public static void OverwriteBuildinPath(string path) public static Persistent GetPersistent(string packageName)
{ {
_buildinPath = path; if (_persitentDic.ContainsKey(packageName) == false)
throw new System.Exception("Should never get here !");
return _persitentDic[packageName];
} }
/// <summary> /// <summary>
/// 重写沙盒跟路径 /// 获取或创建包裹的持久化类
/// </summary> /// </summary>
public static void OverwriteSandboxPath(string path) public static Persistent GetOrCreatePersistent(string packageName)
{ {
_sandboxPath = path; if (_persitentDic.ContainsKey(packageName) == false)
}
/// <summary>
/// 获取沙盒文件夹路径
/// </summary>
public static string GetPersistentRootPath()
{
#if UNITY_EDITOR
// 注意:为了方便调试查看,编辑器下把存储目录放到项目里
if (string.IsNullOrEmpty(_sandboxPath))
{ {
string projectPath = Path.GetDirectoryName(UnityEngine.Application.dataPath); Persistent persistent = new Persistent(packageName);
projectPath = PathUtility.RegularPath(projectPath); _persitentDic.Add(packageName, persistent);
_sandboxPath = PathUtility.Combine(projectPath, SandboxFolderName);
} }
#elif UNITY_STANDALONE return _persitentDic[packageName];
if (string.IsNullOrEmpty(_sandboxPath))
{
_sandboxPath = PathUtility.Combine(UnityEngine.Application.dataPath, SandboxFolderName);
}
#else
if (string.IsNullOrEmpty(_sandboxPath))
{
_sandboxPath = PathUtility.Combine(UnityEngine.Application.persistentDataPath, SandboxFolderName);
}
#endif
return _sandboxPath;
}
/// <summary>
/// 获取基于流文件夹的加载路径
/// </summary>
public static string MakeStreamingLoadPath(string path)
{
if (string.IsNullOrEmpty(_buildinPath))
{
_buildinPath = PathUtility.Combine(UnityEngine.Application.streamingAssetsPath, YooAssetSettings.StreamingAssetsBuildinFolder);
}
return PathUtility.Combine(_buildinPath, path);
}
/// <summary>
/// 获取基于沙盒文件夹的加载路径
/// </summary>
public static string MakePersistentLoadPath(string path)
{
string root = GetPersistentRootPath();
return PathUtility.Combine(root, path);
}
public static string MakePersistentLoadPath(string path1, string path2)
{
string root = GetPersistentRootPath();
return PathUtility.Combine(root, path1, path2);
}
public static string MakePersistentLoadPath(string path1, string path2, string path3)
{
string root = GetPersistentRootPath();
return PathUtility.Combine(root, path1, path2, path3);
} }
/// <summary> /// <summary>
@ -108,109 +47,5 @@ namespace YooAsset
return path; return path;
#endif #endif
} }
/// <summary>
/// 删除沙盒总目录
/// </summary>
public static void DeleteSandbox()
{
string directoryPath = GetPersistentRootPath();
if (Directory.Exists(directoryPath))
Directory.Delete(directoryPath, true);
}
/// <summary>
/// 删除沙盒内的缓存文件夹
/// </summary>
public static void DeleteCacheFolder()
{
string root = MakePersistentLoadPath(CacheFolderName);
if (Directory.Exists(root))
Directory.Delete(root, true);
}
/// <summary>
/// 删除沙盒内的清单文件夹
/// </summary>
public static void DeleteManifestFolder()
{
string root = MakePersistentLoadPath(ManifestFolderName);
if (Directory.Exists(root))
Directory.Delete(root, true);
}
/// <summary>
/// 获取缓存的BundleFile文件夹路径
/// </summary>
private readonly static Dictionary<string, string> _cachedBundleFileFolder = new Dictionary<string, string>(100);
public static string GetCachedBundleFileFolderPath(string packageName)
{
if (_cachedBundleFileFolder.TryGetValue(packageName, out string value) == false)
{
value = MakePersistentLoadPath(CacheFolderName, packageName, CachedBundleFileFolder);
_cachedBundleFileFolder.Add(packageName, value);
}
return value;
}
/// <summary>
/// 获取缓存的RawFile文件夹路径
/// </summary>
private readonly static Dictionary<string, string> _cachedRawFileFolder = new Dictionary<string, string>(100);
public static string GetCachedRawFileFolderPath(string packageName)
{
if (_cachedRawFileFolder.TryGetValue(packageName, out string value) == false)
{
value = MakePersistentLoadPath(CacheFolderName, packageName, CachedRawFileFolder);
_cachedRawFileFolder.Add(packageName, value);
}
return value;
}
/// <summary>
/// 获取应用程序的水印文件路径
/// </summary>
public static string GetAppFootPrintFilePath()
{
return MakePersistentLoadPath(AppFootPrintFileName);
}
/// <summary>
/// 获取沙盒内清单文件的路径
/// </summary>
public static string GetCacheManifestFilePath(string packageName, string packageVersion)
{
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(packageName, packageVersion);
return MakePersistentLoadPath(ManifestFolderName, fileName);
}
/// <summary>
/// 获取沙盒内包裹的哈希文件的路径
/// </summary>
public static string GetCachePackageHashFilePath(string packageName, string packageVersion)
{
string fileName = YooAssetSettingsData.GetPackageHashFileName(packageName, packageVersion);
return MakePersistentLoadPath(ManifestFolderName, fileName);
}
/// <summary>
/// 获取沙盒内包裹的版本文件的路径
/// </summary>
public static string GetCachePackageVersionFilePath(string packageName)
{
string fileName = YooAssetSettingsData.GetPackageVersionFileName(packageName);
return MakePersistentLoadPath(ManifestFolderName, fileName);
}
/// <summary>
/// 保存默认的包裹版本
/// </summary>
public static void SaveCachePackageVersionFile(string packageName, string version)
{
string filePath = GetCachePackageVersionFilePath(packageName);
FileUtility.WriteAllText(filePath, version);
}
} }
} }

View File

@ -217,13 +217,13 @@ namespace YooAsset
if (_steps == ESteps.CheckAppFootPrint) if (_steps == ESteps.CheckAppFootPrint)
{ {
var appFootPrint = new AppFootPrint(); var appFootPrint = new AppFootPrint();
appFootPrint.Load(); appFootPrint.Load(_packageName);
// 如果水印发生变化,则说明覆盖安装后首次打开游戏 // 如果水印发生变化,则说明覆盖安装后首次打开游戏
if (appFootPrint.IsDirty()) if (appFootPrint.IsDirty())
{ {
PersistentTools.DeleteManifestFolder(); PersistentTools.GetPersistent(_packageName).DeleteSandboxManifestFilesFolder();
appFootPrint.Coverage(); appFootPrint.Coverage(_packageName);
YooLogger.Log("Delete manifest files when application foot print dirty !"); YooLogger.Log("Delete manifest files when application foot print dirty !");
} }
_steps = ESteps.QueryCachePackageVersion; _steps = ESteps.QueryCachePackageVersion;
@ -374,16 +374,16 @@ namespace YooAsset
/// <summary> /// <summary>
/// 读取应用程序水印 /// 读取应用程序水印
/// </summary> /// </summary>
public void Load() public void Load(string packageName)
{ {
string footPrintFilePath = PersistentTools.GetAppFootPrintFilePath(); string footPrintFilePath = PersistentTools.GetPersistent(packageName).SandboxAppFootPrintFilePath;
if (File.Exists(footPrintFilePath)) if (File.Exists(footPrintFilePath))
{ {
_footPrint = FileUtility.ReadAllText(footPrintFilePath); _footPrint = FileUtility.ReadAllText(footPrintFilePath);
} }
else else
{ {
Coverage(); Coverage(packageName);
} }
} }
@ -402,14 +402,14 @@ namespace YooAsset
/// <summary> /// <summary>
/// 覆盖掉水印 /// 覆盖掉水印
/// </summary> /// </summary>
public void Coverage() public void Coverage(string packageName)
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
_footPrint = Application.version; _footPrint = Application.version;
#else #else
_footPrint = Application.buildGUID; _footPrint = Application.buildGUID;
#endif #endif
string footPrintFilePath = PersistentTools.GetAppFootPrintFilePath(); string footPrintFilePath = PersistentTools.GetPersistent(packageName).SandboxAppFootPrintFilePath;
FileUtility.WriteAllText(footPrintFilePath, _footPrint); FileUtility.WriteAllText(footPrintFilePath, _footPrint);
YooLogger.Log($"Save application foot print : {_footPrint}"); YooLogger.Log($"Save application foot print : {_footPrint}");
} }

View File

@ -41,7 +41,7 @@ namespace YooAsset
{ {
if (_downloader1 == null) if (_downloader1 == null)
{ {
string savePath = PersistentTools.GetCachePackageHashFilePath(_packageName, _packageVersion); string savePath = PersistentTools.GetPersistent(_packageName).GetSandboxPackageHashFilePath(_packageVersion);
string fileName = YooAssetSettingsData.GetPackageHashFileName(_packageName, _packageVersion); string fileName = YooAssetSettingsData.GetPackageHashFileName(_packageName, _packageVersion);
string webURL = GetDownloadRequestURL(fileName); string webURL = GetDownloadRequestURL(fileName);
YooLogger.Log($"Beginning to download package hash file : {webURL}"); YooLogger.Log($"Beginning to download package hash file : {webURL}");
@ -71,7 +71,7 @@ namespace YooAsset
{ {
if (_downloader2 == null) if (_downloader2 == null)
{ {
string savePath = PersistentTools.GetCacheManifestFilePath(_packageName, _packageVersion); string savePath = PersistentTools.GetPersistent(_packageName).GetSandboxPackageManifestFilePath(_packageVersion);
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_packageName, _packageVersion); string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_packageName, _packageVersion);
string webURL = GetDownloadRequestURL(fileName); string webURL = GetDownloadRequestURL(fileName);
YooLogger.Log($"Beginning to download manifest file : {webURL}"); YooLogger.Log($"Beginning to download manifest file : {webURL}");

View File

@ -41,8 +41,7 @@ namespace YooAsset
{ {
if (_downloader == null) if (_downloader == null)
{ {
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_buildinPackageName, _buildinPackageVersion); string filePath = PersistentTools.GetPersistent(_buildinPackageName).GetBuildinPackageManifestFilePath(_buildinPackageVersion);
string filePath = PersistentTools.MakeStreamingLoadPath(fileName);
string url = PersistentTools.ConvertToWWWPath(filePath); string url = PersistentTools.ConvertToWWWPath(filePath);
_downloader = new UnityWebDataRequester(); _downloader = new UnityWebDataRequester();
_downloader.SendRequest(url); _downloader.SendRequest(url);

View File

@ -67,7 +67,7 @@ namespace YooAsset
if (_steps == ESteps.VerifyFileHash) if (_steps == ESteps.VerifyFileHash)
{ {
_manifestFilePath = PersistentTools.GetCacheManifestFilePath(_packageName, _packageVersion); _manifestFilePath = PersistentTools.GetPersistent(_packageName).GetSandboxPackageManifestFilePath(_packageVersion);
if (File.Exists(_manifestFilePath) == false) if (File.Exists(_manifestFilePath) == false)
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
@ -131,7 +131,7 @@ namespace YooAsset
File.Delete(_manifestFilePath); File.Delete(_manifestFilePath);
} }
string hashFilePath = PersistentTools.GetCachePackageHashFilePath(_packageName, _packageVersion); string hashFilePath = PersistentTools.GetPersistent(_packageName).GetSandboxPackageHashFilePath(_packageVersion);
if (File.Exists(hashFilePath)) if (File.Exists(hashFilePath))
{ {
File.Delete(hashFilePath); File.Delete(hashFilePath);

View File

@ -37,8 +37,7 @@ namespace YooAsset
{ {
if (_downloader == null) if (_downloader == null)
{ {
string fileName = YooAssetSettingsData.GetPackageVersionFileName(_packageName); string filePath = PersistentTools.GetPersistent(_packageName).GetBuildinPackageVersionFilePath();
string filePath = PersistentTools.MakeStreamingLoadPath(fileName);
string url = PersistentTools.ConvertToWWWPath(filePath); string url = PersistentTools.ConvertToWWWPath(filePath);
_downloader = new UnityWebDataRequester(); _downloader = new UnityWebDataRequester();
_downloader.SendRequest(url); _downloader.SendRequest(url);

View File

@ -37,7 +37,7 @@ namespace YooAsset
if (_steps == ESteps.LoadCachePackageHashFile) if (_steps == ESteps.LoadCachePackageHashFile)
{ {
string filePath = PersistentTools.GetCachePackageHashFilePath(_packageName, _packageVersion); string filePath = PersistentTools.GetPersistent(_packageName).GetSandboxPackageHashFilePath(_packageVersion);
if (File.Exists(filePath) == false) if (File.Exists(filePath) == false)
{ {
_steps = ESteps.Done; _steps = ESteps.Done;

View File

@ -35,7 +35,7 @@ namespace YooAsset
if (_steps == ESteps.LoadCachePackageVersionFile) if (_steps == ESteps.LoadCachePackageVersionFile)
{ {
string filePath = PersistentTools.GetCachePackageVersionFilePath(_packageName); string filePath = PersistentTools.GetPersistent(_packageName).GetSandboxPackageVersionFilePath();
if (File.Exists(filePath) == false) if (File.Exists(filePath) == false)
{ {
_steps = ESteps.Done; _steps = ESteps.Done;

View File

@ -31,13 +31,13 @@ namespace YooAsset
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;
if(_steps == ESteps.UnpackManifestHashFile) if (_steps == ESteps.UnpackManifestHashFile)
{ {
if (_downloader1 == null) if (_downloader1 == null)
{ {
string savePath = PersistentTools.GetCachePackageHashFilePath(_buildinPackageName, _buildinPackageVersion); var persistent = PersistentTools.GetPersistent(_buildinPackageName);
string fileName = YooAssetSettingsData.GetPackageHashFileName(_buildinPackageName, _buildinPackageVersion); string savePath = persistent.GetSandboxPackageHashFilePath(_buildinPackageVersion);
string filePath = PersistentTools.MakeStreamingLoadPath(fileName); string filePath = persistent.GetBuildinPackageHashFilePath(_buildinPackageVersion);
string url = PersistentTools.ConvertToWWWPath(filePath); string url = PersistentTools.ConvertToWWWPath(filePath);
_downloader1 = new UnityWebFileRequester(); _downloader1 = new UnityWebFileRequester();
_downloader1.SendRequest(url, savePath); _downloader1.SendRequest(url, savePath);
@ -64,9 +64,9 @@ namespace YooAsset
{ {
if (_downloader2 == null) if (_downloader2 == null)
{ {
string savePath = PersistentTools.GetCacheManifestFilePath(_buildinPackageName, _buildinPackageVersion); var persistent = PersistentTools.GetPersistent(_buildinPackageName);
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_buildinPackageName, _buildinPackageVersion); string savePath = persistent.GetSandboxPackageManifestFilePath(_buildinPackageVersion);
string filePath = PersistentTools.MakeStreamingLoadPath(fileName); string filePath = persistent.GetBuildinPackageManifestFilePath(_buildinPackageVersion);
string url = PersistentTools.ConvertToWWWPath(filePath); string url = PersistentTools.ConvertToWWWPath(filePath);
_downloader2 = new UnityWebFileRequester(); _downloader2 = new UnityWebFileRequester();
_downloader2.SendRequest(url, savePath); _downloader2.SendRequest(url, savePath);

View File

@ -74,13 +74,13 @@ namespace YooAsset
string folderName = FileHash.Substring(0, 2); string folderName = FileHash.Substring(0, 2);
if (IsRawFile) if (IsRawFile)
{ {
string cacheRoot = PersistentTools.GetCachedRawFileFolderPath(PackageName); string cacheRoot = PersistentTools.GetPersistent(PackageName).SandboxCacheRawFilesRoot;
_cachedDataFilePath = PathUtility.Combine(cacheRoot, folderName, CacheGUID, YooAssetSettings.CacheBundleDataFileName); _cachedDataFilePath = PathUtility.Combine(cacheRoot, folderName, CacheGUID, YooAssetSettings.CacheBundleDataFileName);
_cachedDataFilePath += _fileExtension; _cachedDataFilePath += _fileExtension;
} }
else else
{ {
string cacheRoot = PersistentTools.GetCachedBundleFileFolderPath(PackageName); string cacheRoot = PersistentTools.GetPersistent(PackageName).SandboxCacheBundleFilesRoot;
_cachedDataFilePath = PathUtility.Combine(cacheRoot, folderName, CacheGUID, YooAssetSettings.CacheBundleDataFileName); _cachedDataFilePath = PathUtility.Combine(cacheRoot, folderName, CacheGUID, YooAssetSettings.CacheBundleDataFileName);
} }
return _cachedDataFilePath; return _cachedDataFilePath;
@ -101,12 +101,12 @@ namespace YooAsset
string folderName = FileHash.Substring(0, 2); string folderName = FileHash.Substring(0, 2);
if (IsRawFile) if (IsRawFile)
{ {
string cacheRoot = PersistentTools.GetCachedRawFileFolderPath(PackageName); string cacheRoot = PersistentTools.GetPersistent(PackageName).SandboxCacheRawFilesRoot;
_cachedInfoFilePath = PathUtility.Combine(cacheRoot, folderName, CacheGUID, YooAssetSettings.CacheBundleInfoFileName); _cachedInfoFilePath = PathUtility.Combine(cacheRoot, folderName, CacheGUID, YooAssetSettings.CacheBundleInfoFileName);
} }
else else
{ {
string cacheRoot = PersistentTools.GetCachedBundleFileFolderPath(PackageName); string cacheRoot = PersistentTools.GetPersistent(PackageName).SandboxCacheBundleFilesRoot;
_cachedInfoFilePath = PathUtility.Combine(cacheRoot, folderName, CacheGUID, YooAssetSettings.CacheBundleInfoFileName); _cachedInfoFilePath = PathUtility.Combine(cacheRoot, folderName, CacheGUID, YooAssetSettings.CacheBundleInfoFileName);
} }
return _cachedInfoFilePath; return _cachedInfoFilePath;
@ -140,7 +140,8 @@ namespace YooAsset
if (string.IsNullOrEmpty(_streamingFilePath) == false) if (string.IsNullOrEmpty(_streamingFilePath) == false)
return _streamingFilePath; return _streamingFilePath;
_streamingFilePath = PersistentTools.MakeStreamingLoadPath(FileName); string root = PersistentTools.GetPersistent(PackageName).BuildinPackageRoot;
_streamingFilePath = PathUtility.Combine(root, FileName);
return _streamingFilePath; return _streamingFilePath;
} }
} }

View File

@ -74,7 +74,9 @@ namespace YooAsset
public void FlushManifestVersionFile() public void FlushManifestVersionFile()
{ {
if (_activeManifest != null) if (_activeManifest != null)
PersistentTools.SaveCachePackageVersionFile(_packageName, _activeManifest.PackageVersion); {
PersistentTools.GetPersistent(_packageName).SaveSandboxPackageVersionFile(_activeManifest.PackageVersion);
}
} }
private bool IsBuildinPackageBundle(PackageBundle packageBundle) private bool IsBuildinPackageBundle(PackageBundle packageBundle)

View File

@ -37,6 +37,31 @@ namespace YooAsset
/// </summary> /// </summary>
public const string CacheBundleInfoFileName = "__info"; public const string CacheBundleInfoFileName = "__info";
/// <summary>
/// 默认的YooAsset文件夹名称
/// </summary>
public const string DefaultYooFolderName = "yoo";
/// <summary>
/// 缓存的资源文件的文件夹名称
/// </summary>
public const string CachedBundleFileFolder = "CacheBundleFiles";
/// <summary>
/// 缓存的原生文件的文件夹名称
/// </summary>
public const string CachedRawFileFolder = "CacheRawFiles";
/// <summary>
/// 缓存的清单文件的文件夹名称
/// </summary>
public const string ManifestFolderName = "ManifestFiles";
/// <summary>
/// 记录应用程序版本的文件名称
/// </summary>
public const string AppFootPrintFileName = "ApplicationFootPrint.bytes";
/// <summary> /// <summary>
/// 构建输出文件夹名称 /// 构建输出文件夹名称
@ -47,10 +72,5 @@ namespace YooAsset
/// 构建输出的报告文件 /// 构建输出的报告文件
/// </summary> /// </summary>
public const string ReportFileName = "BuildReport"; public const string ReportFileName = "BuildReport";
/// <summary>
/// 内置资源目录名称
/// </summary>
public const string StreamingAssetsBuildinFolder = "BuildinFiles";
} }
} }