mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-25 18:20:15 +00:00
Compare commits
4 Commits
e984d69c48
...
2.3.5-prev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6155256fb6 | ||
|
|
0d4f2bc893 | ||
|
|
600e928ab4 | ||
|
|
4599ff098c |
@@ -2,6 +2,15 @@
|
|||||||
|
|
||||||
All notable changes to this package will be documented in this file.
|
All notable changes to this package will be documented in this file.
|
||||||
|
|
||||||
|
## [2.3.5-preview] - 2025-03-14
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- (#502) 修复了原生缓存文件由于文件格式变动导致的加载本地缓存文件失败的问题。
|
||||||
|
- (#504) 修复了MacOS平台Offline Play Mode模式请求本地资源清单失败的问题。
|
||||||
|
- (#506) 修复了v2.3x版本LoadAllAssets方法计算依赖Bundle不完整的问题。
|
||||||
|
- (#506) 修复了微信小游戏文件系统,在启用加密算法后卸载bundle报错的问题。
|
||||||
|
|
||||||
## [2.3.4-preview] - 2025-03-08
|
## [2.3.4-preview] - 2025-03-08
|
||||||
|
|
||||||
### Improvements
|
### Improvements
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ namespace YooAsset.Editor
|
|||||||
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||||
{
|
{
|
||||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||||
DefaultBuildinFileSystemBuild.ExportBuildinCatalogFile();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ namespace YooAsset.Editor
|
|||||||
if (buildParameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
if (buildParameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||||
{
|
{
|
||||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||||
DefaultBuildinFileSystemBuild.ExportBuildinCatalogFile();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ namespace YooAsset.Editor
|
|||||||
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||||
{
|
{
|
||||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||||
DefaultBuildinFileSystemBuild.ExportBuildinCatalogFile();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 内置资源清单目录
|
/// 内置资源清单目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable]
|
internal class DefaultBuildinFileCatalog : ScriptableObject
|
||||||
internal class DefaultBuildinFileCatalog
|
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class FileWrapper
|
public class FileWrapper
|
||||||
|
|||||||
@@ -338,8 +338,8 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
public string GetCatalogFileLoadPath()
|
public string GetCatalogFileLoadPath()
|
||||||
{
|
{
|
||||||
string fileName = DefaultBuildinFileSystemDefine.BuildinCatalogFileName;
|
string fileName = Path.GetFileNameWithoutExtension(DefaultBuildinFileSystemDefine.BuildinCatalogFileName);
|
||||||
return PathUtility.Combine(YooAssetSettingsData.GetRequestYooDefaultBuildinRoot(), PackageName, fileName);
|
return YooAssetSettingsData.GetYooResourcesLoadPath(PackageName, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -5,16 +5,22 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
public class DefaultBuildinFileSystemBuild
|
public class DefaultBuildinFileSystemBuild : UnityEditor.Build.IPreprocessBuildWithReport
|
||||||
{
|
{
|
||||||
|
public int callbackOrder { get { return 0; } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 输出包裹的内置资源目录文件
|
/// 在构建应用程序前自动生成内置资源目录文件。
|
||||||
|
/// 原理:搜索StreamingAssets目录下的所有资源文件,然后将这些文件信息写入文件,并存储在Resources目录下。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <exception cref="System.Exception"></exception>
|
public void OnPreprocessBuild(UnityEditor.Build.Reporting.BuildReport report)
|
||||||
public static void ExportBuildinCatalogFile()
|
|
||||||
{
|
{
|
||||||
YooLogger.Log("Begin to create catalog file !");
|
YooLogger.Log("Begin to create catalog file !");
|
||||||
|
|
||||||
|
string savePath = YooAssetSettingsData.GetYooResourcesFullPath();
|
||||||
|
if (UnityEditor.AssetDatabase.DeleteAsset(savePath))
|
||||||
|
UnityEditor.AssetDatabase.Refresh();
|
||||||
|
|
||||||
string rootPath = YooAssetSettingsData.GetYooDefaultBuildinRoot();
|
string rootPath = YooAssetSettingsData.GetYooDefaultBuildinRoot();
|
||||||
DirectoryInfo rootDirectory = new DirectoryInfo(rootPath);
|
DirectoryInfo rootDirectory = new DirectoryInfo(rootPath);
|
||||||
if (rootDirectory.Exists == false)
|
if (rootDirectory.Exists == false)
|
||||||
@@ -81,7 +87,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 创建内置清单实例
|
// 创建内置清单实例
|
||||||
var buildinFileCatalog = new DefaultBuildinFileCatalog();
|
var buildinFileCatalog = ScriptableObject.CreateInstance<DefaultBuildinFileCatalog>();
|
||||||
buildinFileCatalog.PackageName = packageName;
|
buildinFileCatalog.PackageName = packageName;
|
||||||
buildinFileCatalog.PackageVersion = packageVersion;
|
buildinFileCatalog.PackageVersion = packageVersion;
|
||||||
|
|
||||||
@@ -105,8 +111,6 @@ namespace YooAsset
|
|||||||
continue;
|
continue;
|
||||||
if (fileInfo.Name == $"{packageName}_{packageVersion}.report")
|
if (fileInfo.Name == $"{packageName}_{packageVersion}.report")
|
||||||
continue;
|
continue;
|
||||||
if (fileInfo.Name == DefaultBuildinFileSystemDefine.BuildinCatalogFileName)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
string fileName = fileInfo.Name;
|
string fileName = fileInfo.Name;
|
||||||
if (fileMapping.TryGetValue(fileName, out string bundleGUID))
|
if (fileMapping.TryGetValue(fileName, out string bundleGUID))
|
||||||
@@ -121,13 +125,18 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 创建输出目录
|
// 创建输出目录
|
||||||
string fullPath = YooAssetSettingsData.GetYooDefaultBuildinRoot();
|
string fullPath = YooAssetSettingsData.GetYooResourcesFullPath();
|
||||||
string saveFilePath = $"{fullPath}/{packageName}/{DefaultBuildinFileSystemDefine.BuildinCatalogFileName}";
|
string saveFilePath = $"{fullPath}/{packageName}/{DefaultBuildinFileSystemDefine.BuildinCatalogFileName}";
|
||||||
FileUtility.CreateFileDirectory(saveFilePath);
|
FileUtility.CreateFileDirectory(saveFilePath);
|
||||||
|
|
||||||
// 创建输出文件
|
// 创建输出文件
|
||||||
File.WriteAllText(saveFilePath, JsonUtility.ToJson(buildinFileCatalog, false));
|
UnityEditor.AssetDatabase.CreateAsset(buildinFileCatalog, saveFilePath);
|
||||||
UnityEditor.AssetDatabase.Refresh();
|
UnityEditor.EditorUtility.SetDirty(buildinFileCatalog);
|
||||||
|
#if UNITY_2019
|
||||||
|
UnityEditor.AssetDatabase.SaveAssets();
|
||||||
|
#else
|
||||||
|
UnityEditor.AssetDatabase.SaveAssetIfDirty(buildinFileCatalog);
|
||||||
|
#endif
|
||||||
|
|
||||||
Debug.Log($"Succeed to save buildin file catalog : {saveFilePath}");
|
Debug.Log($"Succeed to save buildin file catalog : {saveFilePath}");
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -6,6 +6,6 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 内置清单文件名称
|
/// 内置清单文件名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string BuildinCatalogFileName = "BuildinCatalog.json";
|
public const string BuildinCatalogFileName = "BuildinCatalog.asset";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Networking;
|
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
@@ -9,11 +8,9 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
LoadCatalog,
|
LoadCatalog,
|
||||||
WaitForRequest,
|
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private UnityWebRequest _request;
|
|
||||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
@@ -31,39 +28,12 @@ namespace YooAsset
|
|||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string catalogFilePath = _fileSystem.GetCatalogFileLoadPath();
|
|
||||||
|
|
||||||
if (_steps == ESteps.LoadCatalog)
|
if (_steps == ESteps.LoadCatalog)
|
||||||
{
|
{
|
||||||
_request = UnityWebRequest.Get(catalogFilePath);
|
string catalogFilePath = _fileSystem.GetCatalogFileLoadPath();
|
||||||
_request.SendWebRequest();
|
var catalog = Resources.Load<DefaultBuildinFileCatalog>(catalogFilePath);
|
||||||
_steps = ESteps.WaitForRequest;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_steps == ESteps.WaitForRequest)
|
|
||||||
{
|
|
||||||
// 等待请求完成
|
|
||||||
if (!_request.isDone)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (_request.result != UnityWebRequest.Result.Success)
|
|
||||||
{
|
|
||||||
_request.Dispose();
|
|
||||||
_request = null;
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = $"Failed to load catalog file: {_request.error}";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 解析 JSON
|
|
||||||
string jsonText = _request.downloadHandler.text;
|
|
||||||
var catalog = JsonUtility.FromJson<DefaultBuildinFileCatalog>(jsonText);
|
|
||||||
if (catalog == null)
|
if (catalog == null)
|
||||||
{
|
{
|
||||||
_request.Dispose();
|
|
||||||
_request = null;
|
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = $"Failed to load catalog file : {catalogFilePath}";
|
Error = $"Failed to load catalog file : {catalogFilePath}";
|
||||||
@@ -72,8 +42,6 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (catalog.PackageName != _fileSystem.PackageName)
|
if (catalog.PackageName != _fileSystem.PackageName)
|
||||||
{
|
{
|
||||||
_request.Dispose();
|
|
||||||
_request = null;
|
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = $"Catalog file package name {catalog.PackageName} cannot match the file system package name {_fileSystem.PackageName}";
|
Error = $"Catalog file package name {catalog.PackageName} cannot match the file system package name {_fileSystem.PackageName}";
|
||||||
@@ -87,8 +55,6 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
YooLogger.Log($"Package '{_fileSystem.PackageName}' buildin catalog files count : {catalog.Wrappers.Count}");
|
YooLogger.Log($"Package '{_fileSystem.PackageName}' buildin catalog files count : {catalog.Wrappers.Count}");
|
||||||
_request.Dispose();
|
|
||||||
_request = null;
|
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -333,6 +333,13 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
return _records.Keys.ToList();
|
return _records.Keys.ToList();
|
||||||
}
|
}
|
||||||
|
public RecordFileElement GetRecordFileElement(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
if (_records.TryGetValue(bundle.BundleGUID, out RecordFileElement element))
|
||||||
|
return element;
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public string GetTempFilePath(PackageBundle bundle)
|
public string GetTempFilePath(PackageBundle bundle)
|
||||||
{
|
{
|
||||||
@@ -384,10 +391,10 @@ namespace YooAsset
|
|||||||
|
|
||||||
public EFileVerifyResult VerifyCacheFile(PackageBundle bundle)
|
public EFileVerifyResult VerifyCacheFile(PackageBundle bundle)
|
||||||
{
|
{
|
||||||
if (_records.TryGetValue(bundle.BundleGUID, out RecordFileElement wrapper) == false)
|
if (_records.TryGetValue(bundle.BundleGUID, out RecordFileElement element) == false)
|
||||||
return EFileVerifyResult.CacheNotFound;
|
return EFileVerifyResult.CacheNotFound;
|
||||||
|
|
||||||
EFileVerifyResult result = FileVerifyHelper.FileVerify(wrapper.DataFilePath, wrapper.DataFileSize, wrapper.DataFileCRC, EFileVerifyLevel.High);
|
EFileVerifyResult result = FileVerifyHelper.FileVerify(element.DataFilePath, element.DataFileSize, element.DataFileCRC, EFileVerifyLevel.High);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
public bool WriteCacheBundleFile(PackageBundle bundle, string copyPath)
|
public bool WriteCacheBundleFile(PackageBundle bundle, string copyPath)
|
||||||
@@ -427,22 +434,10 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
public bool DeleteCacheBundleFile(string bundleGUID)
|
public bool DeleteCacheBundleFile(string bundleGUID)
|
||||||
{
|
{
|
||||||
if (_records.TryGetValue(bundleGUID, out RecordFileElement wrapper))
|
if (_records.TryGetValue(bundleGUID, out RecordFileElement element))
|
||||||
{
|
{
|
||||||
try
|
_records.Remove(bundleGUID);
|
||||||
{
|
return element.DeleteFolder();
|
||||||
string dataFilePath = wrapper.DataFilePath;
|
|
||||||
FileInfo fileInfo = new FileInfo(dataFilePath);
|
|
||||||
if (fileInfo.Exists)
|
|
||||||
fileInfo.Directory.Delete(true);
|
|
||||||
_records.Remove(bundleGUID);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
YooLogger.Error($"Failed to delete cache file ! {e.Message}");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal class RecordFileElement
|
internal class RecordFileElement
|
||||||
@@ -7,7 +9,7 @@ namespace YooAsset
|
|||||||
public string DataFilePath { private set; get; }
|
public string DataFilePath { private set; get; }
|
||||||
public string DataFileCRC { private set; get; }
|
public string DataFileCRC { private set; get; }
|
||||||
public long DataFileSize { private set; get; }
|
public long DataFileSize { private set; get; }
|
||||||
|
|
||||||
public RecordFileElement(string infoFilePath, string dataFilePath, string dataFileCRC, long dataFileSize)
|
public RecordFileElement(string infoFilePath, string dataFilePath, string dataFileCRC, long dataFileSize)
|
||||||
{
|
{
|
||||||
InfoFilePath = infoFilePath;
|
InfoFilePath = infoFilePath;
|
||||||
@@ -15,5 +17,31 @@ namespace YooAsset
|
|||||||
DataFileCRC = dataFileCRC;
|
DataFileCRC = dataFileCRC;
|
||||||
DataFileSize = dataFileSize;
|
DataFileSize = dataFileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除记录文件
|
||||||
|
/// </summary>
|
||||||
|
public bool DeleteFolder()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string directory = Path.GetDirectoryName(InfoFilePath);
|
||||||
|
DirectoryInfo directoryInfo = new DirectoryInfo(directory);
|
||||||
|
if (directoryInfo.Exists)
|
||||||
|
{
|
||||||
|
directoryInfo.Delete(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
YooLogger.Error($"Failed to delete cache file ! {e.Message}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.IO;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
@@ -260,9 +261,30 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
if (_fileSystem.Exists(_bundle))
|
if (_fileSystem.Exists(_bundle))
|
||||||
{
|
{
|
||||||
DownloadProgress = 1f;
|
// 注意:缓存的原生文件的格式,可能会在业务端根据需求发生变动!
|
||||||
DownloadedBytes = _bundle.FileSize;
|
// 注意:这里需要校验文件格式,如果不一致对本地文件进行修正!
|
||||||
_steps = ESteps.LoadCacheRawBundle;
|
string filePath = _fileSystem.GetCacheBundleFileLoadPath(_bundle);
|
||||||
|
if (File.Exists(filePath) == false)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var recordFileElement = _fileSystem.GetRecordFileElement(_bundle);
|
||||||
|
File.Move(recordFileElement.DataFilePath, filePath);
|
||||||
|
_steps = ESteps.LoadCacheRawBundle;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"Faild rename raw data file : {e.Message}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DownloadProgress = 1f;
|
||||||
|
DownloadedBytes = _bundle.FileSize;
|
||||||
|
_steps = ESteps.LoadCacheRawBundle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,9 +7,10 @@ namespace YooAsset
|
|||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
CheckManifest,
|
||||||
CheckArgs,
|
CheckArgs,
|
||||||
GetTagsCacheFiles,
|
GetClearCacheFiles,
|
||||||
ClearTagsCacheFiles,
|
ClearFilterCacheFiles,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,13 +30,27 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
_steps = ESteps.CheckArgs;
|
_steps = ESteps.CheckManifest;
|
||||||
}
|
}
|
||||||
internal override void InternalUpdate()
|
internal override void InternalUpdate()
|
||||||
{
|
{
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.CheckManifest)
|
||||||
|
{
|
||||||
|
if (_manifest == null)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = "Can not found active package manifest !";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.CheckArgs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.CheckArgs)
|
if (_steps == ESteps.CheckArgs)
|
||||||
{
|
{
|
||||||
if (_clearParam == null)
|
if (_clearParam == null)
|
||||||
@@ -67,17 +82,17 @@ namespace YooAsset
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_steps = ESteps.GetTagsCacheFiles;
|
_steps = ESteps.GetClearCacheFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.GetTagsCacheFiles)
|
if (_steps == ESteps.GetClearCacheFiles)
|
||||||
{
|
{
|
||||||
_clearBundleGUIDs = GetTagsBundleGUIDs();
|
_clearBundleGUIDs = GetBundleGUIDsByTag();
|
||||||
_clearFileTotalCount = _clearBundleGUIDs.Count;
|
_clearFileTotalCount = _clearBundleGUIDs.Count;
|
||||||
_steps = ESteps.ClearTagsCacheFiles;
|
_steps = ESteps.ClearFilterCacheFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.ClearTagsCacheFiles)
|
if (_steps == ESteps.ClearFilterCacheFiles)
|
||||||
{
|
{
|
||||||
for (int i = _clearBundleGUIDs.Count - 1; i >= 0; i--)
|
for (int i = _clearBundleGUIDs.Count - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
@@ -100,7 +115,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private List<string> GetTagsBundleGUIDs()
|
private List<string> GetBundleGUIDsByTag()
|
||||||
{
|
{
|
||||||
var allBundleGUIDs = _fileSystem.GetAllCachedBundleGUIDs();
|
var allBundleGUIDs = _fileSystem.GetAllCachedBundleGUIDs();
|
||||||
List<string> result = new List<string>(allBundleGUIDs.Count);
|
List<string> result = new List<string>(allBundleGUIDs.Count);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ namespace YooAsset
|
|||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
CheckManifest,
|
||||||
GetUnusedCacheFiles,
|
GetUnusedCacheFiles,
|
||||||
ClearUnusedCacheFiles,
|
ClearUnusedCacheFiles,
|
||||||
Done,
|
Done,
|
||||||
@@ -19,7 +20,7 @@ namespace YooAsset
|
|||||||
private int _unusedFileTotalCount = 0;
|
private int _unusedFileTotalCount = 0;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
|
||||||
internal ClearUnusedCacheBundleFilesOperation(DefaultCacheFileSystem fileSystem, PackageManifest manifest)
|
internal ClearUnusedCacheBundleFilesOperation(DefaultCacheFileSystem fileSystem, PackageManifest manifest)
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
@@ -27,15 +28,29 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
_steps = ESteps.GetUnusedCacheFiles;
|
_steps = ESteps.CheckManifest;
|
||||||
}
|
}
|
||||||
internal override void InternalUpdate()
|
internal override void InternalUpdate()
|
||||||
{
|
{
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.CheckManifest)
|
||||||
|
{
|
||||||
|
if (_manifest == null)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = "Can not found active package manifest !";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.GetUnusedCacheFiles;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.GetUnusedCacheFiles)
|
if (_steps == ESteps.GetUnusedCacheFiles)
|
||||||
{
|
{
|
||||||
_unusedBundleGUIDs = GetUnusedBundleGUIDs();
|
_unusedBundleGUIDs = GetUnusedBundleGUIDs();
|
||||||
_unusedFileTotalCount = _unusedBundleGUIDs.Count;
|
_unusedFileTotalCount = _unusedBundleGUIDs.Count;
|
||||||
_steps = ESteps.ClearUnusedCacheFiles;
|
_steps = ESteps.ClearUnusedCacheFiles;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ namespace YooAsset
|
|||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
CheckManifest,
|
||||||
ClearUnusedCacheFiles,
|
ClearUnusedCacheFiles,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
@@ -24,13 +25,27 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
_steps = ESteps.ClearUnusedCacheFiles;
|
_steps = ESteps.CheckManifest;
|
||||||
}
|
}
|
||||||
internal override void InternalUpdate()
|
internal override void InternalUpdate()
|
||||||
{
|
{
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.CheckManifest)
|
||||||
|
{
|
||||||
|
if (_manifest == null)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = "Can not found active package manifest !";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.ClearUnusedCacheFiles;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.ClearUnusedCacheFiles)
|
if (_steps == ESteps.ClearUnusedCacheFiles)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -92,12 +92,7 @@ namespace YooAsset
|
|||||||
if (_fileSystem.AppendFileExtension)
|
if (_fileSystem.AppendFileExtension)
|
||||||
{
|
{
|
||||||
string dataFileExtension = FindDataFileExtension(chidDirectory);
|
string dataFileExtension = FindDataFileExtension(chidDirectory);
|
||||||
if (string.IsNullOrEmpty(dataFileExtension))
|
if (string.IsNullOrEmpty(dataFileExtension) == false)
|
||||||
{
|
|
||||||
//注意:覆盖安装的情况下,缓存文件可能会没有后缀格式,需要删除重新下载!
|
|
||||||
dataFilePath = string.Empty;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
dataFilePath += dataFileExtension;
|
dataFilePath += dataFileExtension;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ using System.IO;
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Networking;
|
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
@@ -13,11 +12,9 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
LoadCatalog,
|
LoadCatalog,
|
||||||
WaitForRequest,
|
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private UnityWebRequest _request;
|
|
||||||
private readonly DefaultWebServerFileSystem _fileSystem;
|
private readonly DefaultWebServerFileSystem _fileSystem;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
@@ -39,39 +36,12 @@ namespace YooAsset
|
|||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string catalogFilePath = _fileSystem.GetCatalogFileLoadPath();
|
|
||||||
|
|
||||||
if (_steps == ESteps.LoadCatalog)
|
if (_steps == ESteps.LoadCatalog)
|
||||||
{
|
{
|
||||||
_request = UnityWebRequest.Get(catalogFilePath);
|
string catalogFilePath = _fileSystem.GetCatalogFileLoadPath();
|
||||||
_request.SendWebRequest();
|
var catalog = Resources.Load<DefaultBuildinFileCatalog>(catalogFilePath);
|
||||||
_steps = ESteps.WaitForRequest;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_steps == ESteps.WaitForRequest)
|
|
||||||
{
|
|
||||||
// 等待请求完成
|
|
||||||
if (!_request.isDone)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (_request.result != UnityWebRequest.Result.Success)
|
|
||||||
{
|
|
||||||
_request.Dispose();
|
|
||||||
_request = null;
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = $"Failed to load web server catalog file: {_request.error}";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 解析 JSON
|
|
||||||
string jsonText = _request.downloadHandler.text;
|
|
||||||
var catalog = JsonUtility.FromJson<DefaultBuildinFileCatalog>(jsonText);
|
|
||||||
if (catalog == null)
|
if (catalog == null)
|
||||||
{
|
{
|
||||||
_request.Dispose();
|
|
||||||
_request = null;
|
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = $"Failed to load web server catalog file : {catalogFilePath}";
|
Error = $"Failed to load web server catalog file : {catalogFilePath}";
|
||||||
@@ -80,8 +50,6 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (catalog.PackageName != _fileSystem.PackageName)
|
if (catalog.PackageName != _fileSystem.PackageName)
|
||||||
{
|
{
|
||||||
_request.Dispose();
|
|
||||||
_request = null;
|
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = $"Web server catalog file package name {catalog.PackageName} cannot match the file system package name {_fileSystem.PackageName}";
|
Error = $"Web server catalog file package name {catalog.PackageName} cannot match the file system package name {_fileSystem.PackageName}";
|
||||||
@@ -96,8 +64,6 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
YooLogger.Log($"Package '{_fileSystem.PackageName}' catalog files count : {catalog.Wrappers.Count}");
|
YooLogger.Log($"Package '{_fileSystem.PackageName}' catalog files count : {catalog.Wrappers.Count}");
|
||||||
_request.Dispose();
|
|
||||||
_request = null;
|
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ namespace YooAsset
|
|||||||
/// <param name="clearParam">执行参数</param>
|
/// <param name="clearParam">执行参数</param>
|
||||||
public ClearCacheFilesOperation ClearCacheFilesAsync(EFileClearMode clearMode, object clearParam = null)
|
public ClearCacheFilesOperation ClearCacheFilesAsync(EFileClearMode clearMode, object clearParam = null)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize(false);
|
||||||
var operation = _playModeImpl.ClearCacheFilesAsync(clearMode.ToString(), clearParam);
|
var operation = _playModeImpl.ClearCacheFilesAsync(clearMode.ToString(), clearParam);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
@@ -276,7 +276,7 @@ namespace YooAsset
|
|||||||
/// <param name="clearParam">执行参数</param>
|
/// <param name="clearParam">执行参数</param>
|
||||||
public ClearCacheFilesOperation ClearCacheFilesAsync(string clearMode, object clearParam = null)
|
public ClearCacheFilesOperation ClearCacheFilesAsync(string clearMode, object clearParam = null)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize(false);
|
||||||
var operation = _playModeImpl.ClearCacheFilesAsync(clearMode, clearParam);
|
var operation = _playModeImpl.ClearCacheFilesAsync(clearMode, clearParam);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
|
|||||||
@@ -220,26 +220,6 @@ namespace YooAsset
|
|||||||
else
|
else
|
||||||
return PathUtility.Combine(Application.streamingAssetsPath, Setting.DefaultYooFolderName);
|
return PathUtility.Combine(Application.streamingAssetsPath, Setting.DefaultYooFolderName);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static string GetRequestYooDefaultBuildinRoot()
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(Setting.DefaultYooFolderName))
|
|
||||||
return GetRequestStreamingAssetsPath();
|
|
||||||
else
|
|
||||||
return PathUtility.Combine(GetRequestStreamingAssetsPath(), Setting.DefaultYooFolderName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取UnityWebRequest StreamingAssets的路径 (OSX and iOS 需要加 file://)
|
|
||||||
/// </summary>
|
|
||||||
internal static string GetRequestStreamingAssetsPath()
|
|
||||||
{
|
|
||||||
#if UNITY_STANDALONE_OSX || UNITY_IOS
|
|
||||||
return $"file://{Application.streamingAssetsPath}";
|
|
||||||
#else
|
|
||||||
return Application.streamingAssetsPath;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "com.tuyoogame.yooasset",
|
"name": "com.tuyoogame.yooasset",
|
||||||
"displayName": "YooAsset",
|
"displayName": "YooAsset",
|
||||||
"version": "2.3.4-preview",
|
"version": "2.3.5-preview",
|
||||||
"unity": "2019.4",
|
"unity": "2019.4",
|
||||||
"description": "unity3d resources management system.",
|
"description": "unity3d resources management system.",
|
||||||
"author": {
|
"author": {
|
||||||
|
|||||||
Reference in New Issue
Block a user