diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdateBundleInfo.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdateBundleInfo.cs
index ab7e63f..c13c4c1 100644
--- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdateBundleInfo.cs
+++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdateBundleInfo.cs
@@ -1,5 +1,6 @@
using System;
using System.IO;
+using System.Text;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
@@ -130,7 +131,7 @@ namespace YooAsset.Editor
{
var buildMode = buildParametersContext.Parameters.BuildMode;
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
- return "00000000000000000000000000000000"; //32位
+ return GetFilePathTempHash(filePath);
else
return HashUtility.FileMD5(filePath);
}
@@ -150,5 +151,32 @@ namespace YooAsset.Editor
else
return FileUtility.GetFileSize(filePath);
}
+
+ protected string GetFilePathTempHash(string filePath)
+ {
+ byte[] bytes = Encoding.UTF8.GetBytes(filePath);
+ return HashUtility.BytesMD5(bytes);
+
+ // 注意:在文件路径的哈希值冲突的情况下,可以使用下面的方法
+ //return $"{HashUtility.BytesMD5(bytes)}-{Guid.NewGuid():N}";
+ }
+ protected long GetBundleTempSize(BuildBundleInfo bundleInfo)
+ {
+ long tempSize = 0;
+
+ var assetPaths = bundleInfo.GetAllMainAssetPaths();
+ foreach (var assetPath in assetPaths)
+ {
+ long size = FileUtility.GetFileSize(assetPath);
+ tempSize += size;
+ }
+
+ if (tempSize == 0)
+ {
+ string message = $"Bundle temp size is zero, check bundle main asset list : {bundleInfo.BundleName}";
+ throw new Exception(message);
+ }
+ return tempSize;
+ }
}
}
\ No newline at end of file
diff --git a/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs b/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs
index 948a2da..7c07bff 100644
--- a/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs
+++ b/Assets/YooAsset/Runtime/CacheSystem/CacheSystem.cs
@@ -90,6 +90,15 @@ namespace YooAsset
}
}
+ ///
+ /// 获取记录对象
+ ///
+ public static PackageCache.RecordWrapper TryGetWrapper(string packageName, string cacheGUID)
+ {
+ var cache = GetOrCreateCache(packageName);
+ return cache.TryGetWrapper(cacheGUID);
+ }
+
///
/// 验证缓存文件(子线程内操作)
///
@@ -165,9 +174,9 @@ namespace YooAsset
///
/// 获取所有的缓存文件
///
- public static List GetAllCacheGUIDs(ResourcePackage package)
+ public static List GetAllCacheGUIDs(string packageName)
{
- var cache = GetOrCreateCache(package.PackageName);
+ var cache = GetOrCreateCache(packageName);
return cache.GetAllKeys();
}
diff --git a/Assets/YooAsset/Runtime/CacheSystem/Operations/ClearAllCacheFilesOperation.cs b/Assets/YooAsset/Runtime/CacheSystem/Operations/ClearAllCacheFilesOperation.cs
index adb77d3..37ddb90 100644
--- a/Assets/YooAsset/Runtime/CacheSystem/Operations/ClearAllCacheFilesOperation.cs
+++ b/Assets/YooAsset/Runtime/CacheSystem/Operations/ClearAllCacheFilesOperation.cs
@@ -37,7 +37,7 @@ namespace YooAsset
if (_steps == ESteps.GetAllCacheFiles)
{
- _allCacheGUIDs = CacheSystem.GetAllCacheGUIDs(_package);
+ _allCacheGUIDs = CacheSystem.GetAllCacheGUIDs(_package.PackageName);
_fileTotalCount = _allCacheGUIDs.Count;
YooLogger.Log($"Found all cache file count : {_fileTotalCount}");
_steps = ESteps.ClearAllCacheFiles;
diff --git a/Assets/YooAsset/Runtime/CacheSystem/Operations/GetAllCacheFileInfosOperation.cs b/Assets/YooAsset/Runtime/CacheSystem/Operations/GetAllCacheFileInfosOperation.cs
new file mode 100644
index 0000000..bee5562
--- /dev/null
+++ b/Assets/YooAsset/Runtime/CacheSystem/Operations/GetAllCacheFileInfosOperation.cs
@@ -0,0 +1,85 @@
+using System;
+using System.IO;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace YooAsset
+{
+ public class GetAllCacheFileInfosOperation : AsyncOperationBase
+ {
+ public class CacheInfo
+ {
+ public string FishHash { private set; get; }
+ public string FilePath { private set; get; }
+ public string FileCRC { private set; get; }
+ public long FileSize { private set; get; }
+
+ public CacheInfo(string fishHash, string filePath, string fileCRC, long fileSize)
+ {
+ FishHash = fishHash;
+ FilePath = filePath;
+ FileCRC = fileCRC;
+ FileSize = fileSize;
+ }
+ }
+
+ private enum ESteps
+ {
+ None,
+ GetCacheFileInfos,
+ Done,
+ }
+
+ private readonly string _packageName;
+ private ESteps _steps = ESteps.None;
+ private List _cacheFileInfos;
+
+ ///
+ /// 搜索结果
+ ///
+ public List Result
+ {
+ get { return _cacheFileInfos; }
+ }
+
+ internal GetAllCacheFileInfosOperation(string packageName)
+ {
+ _packageName = packageName;
+ }
+ internal override void Start()
+ {
+ _steps = ESteps.GetCacheFileInfos;
+ }
+ internal override void Update()
+ {
+ if (_steps == ESteps.None || _steps == ESteps.Done)
+ return;
+
+ if (_steps == ESteps.GetCacheFileInfos)
+ {
+ var allCachedGUIDs = CacheSystem.GetAllCacheGUIDs(_packageName);
+ _cacheFileInfos = new List(allCachedGUIDs.Count);
+ for (int i = 0; i < allCachedGUIDs.Count; i++)
+ {
+ var cachedGUID = allCachedGUIDs[i];
+ var wrapper = CacheSystem.TryGetWrapper(_packageName, cachedGUID);
+ if (wrapper != null)
+ {
+ string directoryName = Path.GetDirectoryName(wrapper.DataFilePath);
+ var directoryInfo = new DirectoryInfo(directoryName);
+ if (directoryInfo.Exists)
+ {
+ string fishHash = directoryInfo.Name;
+ var cacheFileInfo = new CacheInfo(fishHash, wrapper.DataFilePath, wrapper.DataFileCRC, wrapper.DataFileSize);
+ _cacheFileInfos.Add(cacheFileInfo);
+ }
+ }
+ }
+
+ // 注意:总是返回成功
+ _steps = ESteps.Done;
+ Status = EOperationStatus.Succeed;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/YooAsset/Runtime/CacheSystem/Operations/GetAllCacheFileInfosOperation.cs.meta b/Assets/YooAsset/Runtime/CacheSystem/Operations/GetAllCacheFileInfosOperation.cs.meta
new file mode 100644
index 0000000..d029471
--- /dev/null
+++ b/Assets/YooAsset/Runtime/CacheSystem/Operations/GetAllCacheFileInfosOperation.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: d37e37f5d78ddf8468adcf2dff1edfbb
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/YooAsset/Runtime/CacheSystem/PersistentTools.cs b/Assets/YooAsset/Runtime/CacheSystem/PersistentTools.cs
index 4a2aefb..e5eee92 100644
--- a/Assets/YooAsset/Runtime/CacheSystem/PersistentTools.cs
+++ b/Assets/YooAsset/Runtime/CacheSystem/PersistentTools.cs
@@ -37,18 +37,23 @@ namespace YooAsset
{
#if UNITY_EDITOR
return StringUtility.Format("file:///{0}", path);
-#elif UNITY_IPHONE
- return StringUtility.Format("file://{0}", path);
-#elif UNITY_ANDROID
- return path;
-#elif UNITY_STANDALONE_OSX
- return new System.Uri(path).ToString();
-#elif UNITY_STANDALONE
- return StringUtility.Format("file:///{0}", path);
#elif UNITY_WEBGL
- return path;
+ return path;
+#elif UNITY_IPHONE
+ return StringUtility.Format("file://{0}", path);
+#elif UNITY_ANDROID
+ if (path.StartsWith("jar:file://"))
+ return path;
+ else
+ return StringUtility.Format("jar:file://{0}", path);
+#elif UNITY_STANDALONE_OSX
+ return new System.Uri(path).ToString();
+#elif UNITY_STANDALONE
+ return StringUtility.Format("file:///{0}", path);
#elif UNITY_OPENHARMONY
return path;
+#else
+ return path;
#endif
}
}
diff --git a/Assets/YooAsset/Runtime/PackageSystem/ManifestTools.cs b/Assets/YooAsset/Runtime/PackageSystem/ManifestTools.cs
index e096143..9895bb0 100644
--- a/Assets/YooAsset/Runtime/PackageSystem/ManifestTools.cs
+++ b/Assets/YooAsset/Runtime/PackageSystem/ManifestTools.cs
@@ -154,10 +154,12 @@ namespace YooAsset
// 填充BundleDic
manifest.BundleDic = new Dictionary(manifest.BundleList.Count);
+ manifest.BundleDic2 = new Dictionary(manifest.BundleList.Count);
foreach (var packageBundle in manifest.BundleList)
{
packageBundle.ParseBundle(manifest.PackageName, manifest.OutputNameStyle);
manifest.BundleDic.Add(packageBundle.BundleName, packageBundle);
+ manifest.BundleDic2.Add(packageBundle.FileName, packageBundle);
}
// 填充AssetDic
@@ -210,7 +212,18 @@ namespace YooAsset
}
///
- /// 批量转换为解压BundleInfo
+ /// 转换为导入BundleInfo
+ ///
+ public static BundleInfo ConvertToImportInfo(PackageBundle packageBundle, string filePath)
+ {
+ // 注意:我们把本地文件路径指定为远端下载地址
+ string persistentPath = PersistentTools.ConvertToWWWPath(filePath);
+ BundleInfo bundleInfo = new BundleInfo(packageBundle, BundleInfo.ELoadMode.None, persistentPath, persistentPath);
+ return bundleInfo;
+ }
+
+ ///
+ /// 批量转换解压为BundleInfo
///
public static List ConvertToUnpackInfos(List unpackList)
{
diff --git a/Assets/YooAsset/Runtime/PackageSystem/Operations/DownloaderOperation.cs b/Assets/YooAsset/Runtime/PackageSystem/Operations/DownloaderOperation.cs
index 6d727e4..e12061b 100644
--- a/Assets/YooAsset/Runtime/PackageSystem/Operations/DownloaderOperation.cs
+++ b/Assets/YooAsset/Runtime/PackageSystem/Operations/DownloaderOperation.cs
@@ -91,14 +91,7 @@ namespace YooAsset
_failedTryAgain = failedTryAgain;
_timeout = timeout;
- if (downloadList != null)
- {
- TotalDownloadCount = downloadList.Count;
- foreach (var packageBundle in downloadList)
- {
- TotalDownloadBytes += packageBundle.Bundle.FileSize;
- }
- }
+ CalculatDownloaderInfo();
}
internal override void Start()
{
@@ -206,6 +199,57 @@ namespace YooAsset
}
}
}
+ private void CalculatDownloaderInfo()
+ {
+ if (_downloadList != null)
+ {
+ TotalDownloadBytes = 0;
+ TotalDownloadCount = _downloadList.Count;
+ foreach (var packageBundle in _downloadList)
+ {
+ TotalDownloadBytes += packageBundle.Bundle.FileSize;
+ }
+ }
+ else
+ {
+ TotalDownloadBytes = 0;
+ TotalDownloadCount = 0;
+ }
+ }
+
+ ///
+ /// 合并其它下载器
+ ///
+ /// 合并的下载器
+ public void Combine(DownloaderOperation downloader)
+ {
+ if (_steps != ESteps.None)
+ {
+ YooLogger.Error("The downloader is running, can not combine with other downloader !");
+ return;
+ }
+
+ HashSet temper = new HashSet();
+ foreach (var bundleInfo in _downloadList)
+ {
+ if (temper.Contains(bundleInfo.Bundle.CachedDataFilePath) == false)
+ {
+ temper.Add(bundleInfo.Bundle.CachedDataFilePath);
+ }
+ }
+
+ // 合并下载列表
+ foreach (var bundleInfo in downloader._downloadList)
+ {
+ if (temper.Contains(bundleInfo.Bundle.CachedDataFilePath) == false)
+ {
+ _downloadList.Add(bundleInfo);
+ }
+ }
+
+ // 重新统计下载信息
+ CalculatDownloaderInfo();
+ }
///
/// 开始下载
@@ -282,4 +326,21 @@ namespace YooAsset
return operation;
}
}
+ public sealed class ResourceImporterOperation : DownloaderOperation
+ {
+ internal ResourceImporterOperation(List downloadList, int downloadingMaxNumber, int failedTryAgain, int timeout)
+ : base(downloadList, downloadingMaxNumber, failedTryAgain, timeout)
+ {
+ }
+
+ ///
+ /// 创建空的导入器
+ ///
+ internal static ResourceImporterOperation CreateEmptyImporter(int upackingMaxNumber, int failedTryAgain, int timeout)
+ {
+ List downloadList = new List();
+ var operation = new ResourceImporterOperation(downloadList, upackingMaxNumber, failedTryAgain, int.MaxValue);
+ return operation;
+ }
+ }
}
\ No newline at end of file
diff --git a/Assets/YooAsset/Runtime/PackageSystem/Operations/InitializationOperation.cs b/Assets/YooAsset/Runtime/PackageSystem/Operations/InitializationOperation.cs
index 092b000..5d68da0 100644
--- a/Assets/YooAsset/Runtime/PackageSystem/Operations/InitializationOperation.cs
+++ b/Assets/YooAsset/Runtime/PackageSystem/Operations/InitializationOperation.cs
@@ -11,6 +11,11 @@ namespace YooAsset
public abstract class InitializationOperation : AsyncOperationBase
{
public string PackageVersion { protected set; get; }
+
+ ///
+ /// 本地记录的资源包裹的版本
+ ///
+ public string RecordVersion { protected set; get; }
}
///
@@ -242,6 +247,7 @@ namespace YooAsset
if (_queryCachePackageVersionOp.Status == EOperationStatus.Succeed)
{
+ RecordVersion = _queryCachePackageVersionOp.PackageVersion;
_steps = ESteps.TryLoadCacheManifest;
}
else
diff --git a/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/DeserializeManifestOperation.cs b/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/DeserializeManifestOperation.cs
index 14fffae..37407a8 100644
--- a/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/DeserializeManifestOperation.cs
+++ b/Assets/YooAsset/Runtime/PackageSystem/Operations/Internal/DeserializeManifestOperation.cs
@@ -189,6 +189,8 @@ namespace YooAsset
_packageBundleCount = _buffer.ReadInt32();
Manifest.BundleList = new List(_packageBundleCount);
Manifest.BundleDic = new Dictionary(_packageBundleCount);
+ Manifest.BundleDic2 = new Dictionary(_packageBundleCount);
+ Manifest.BundleDic3 = new Dictionary(_packageBundleCount);
_progressTotalValue = _packageBundleCount;
_steps = ESteps.DeserializeBundleList;
}
@@ -210,10 +212,11 @@ namespace YooAsset
packageBundle.ParseBundle(Manifest.PackageName, Manifest.OutputNameStyle);
Manifest.BundleDic.Add(packageBundle.BundleName, packageBundle);
+ Manifest.BundleDic2.Add(packageBundle.FileName, packageBundle);
// 注意:原始文件可能存在相同的CacheGUID
- if (Manifest.CacheGUIDs.Contains(packageBundle.CacheGUID) == false)
- Manifest.CacheGUIDs.Add(packageBundle.CacheGUID);
+ if (Manifest.BundleDic3.ContainsKey(packageBundle.CacheGUID) == false)
+ Manifest.BundleDic3.Add(packageBundle.CacheGUID, packageBundle);
_packageBundleCount--;
Progress = 1f - _packageBundleCount / _progressTotalValue;
diff --git a/Assets/YooAsset/Runtime/PackageSystem/PackageManifest.cs b/Assets/YooAsset/Runtime/PackageSystem/PackageManifest.cs
index 4db8926..9d252a0 100644
--- a/Assets/YooAsset/Runtime/PackageSystem/PackageManifest.cs
+++ b/Assets/YooAsset/Runtime/PackageSystem/PackageManifest.cs
@@ -64,6 +64,18 @@ namespace YooAsset
[NonSerialized]
public Dictionary BundleDic;
+ ///
+ /// 资源包集合(提供FileName获取PackageBundle)
+ ///
+ [NonSerialized]
+ public Dictionary BundleDic2;
+
+ ///
+ /// 资源包集合(提供CacheGUID获取PackageBundle)
+ ///
+ [NonSerialized]
+ public Dictionary BundleDic3;
+
///
/// 资源映射集合(提供AssetPath获取PackageAsset)
///
@@ -82,12 +94,6 @@ namespace YooAsset
[NonSerialized]
public Dictionary AssetPathMapping2;
- ///
- /// 该资源清单所有文件的缓存GUID集合
- ///
- [NonSerialized]
- public HashSet CacheGUIDs = new HashSet();
-
///
/// 尝试映射为资源路径
@@ -192,12 +198,28 @@ namespace YooAsset
return BundleDic.TryGetValue(bundleName, out result);
}
+ ///
+ /// 尝试获取包裹的资源包
+ ///
+ public bool TryGetPackageBundleByFileName(string fileName, out PackageBundle result)
+ {
+ return BundleDic2.TryGetValue(fileName, out result);
+ }
+
+ ///
+ /// 尝试获取包裹的资源包
+ ///
+ public bool TryGetPackageBundleByCacheGUID(string cacheGUID, out PackageBundle result)
+ {
+ return BundleDic3.TryGetValue(cacheGUID, out result);
+ }
+
///
/// 是否包含资源文件
///
public bool IsIncludeBundleFile(string cacheGUID)
{
- return CacheGUIDs.Contains(cacheGUID);
+ return BundleDic3.ContainsKey(cacheGUID);
}
///
diff --git a/Assets/YooAsset/Runtime/PackageSystem/PlayMode/EditorSimulateModeImpl.cs b/Assets/YooAsset/Runtime/PackageSystem/PlayMode/EditorSimulateModeImpl.cs
index 50f8933..a2e7807 100644
--- a/Assets/YooAsset/Runtime/PackageSystem/PlayMode/EditorSimulateModeImpl.cs
+++ b/Assets/YooAsset/Runtime/PackageSystem/PlayMode/EditorSimulateModeImpl.cs
@@ -74,6 +74,11 @@ namespace YooAsset
{
return ResourceUnpackerOperation.CreateEmptyUnpacker(upackingMaxNumber, failedTryAgain, timeout);
}
+
+ ResourceImporterOperation IPlayModeServices.CreateResourceImporterByFilePaths(string[] filePaths, int importerMaxNumber, int failedTryAgain, int timeout)
+ {
+ return ResourceImporterOperation.CreateEmptyImporter(importerMaxNumber, failedTryAgain, timeout);
+ }
#endregion
#region IBundleServices接口
diff --git a/Assets/YooAsset/Runtime/PackageSystem/PlayMode/HostPlayModeImpl.cs b/Assets/YooAsset/Runtime/PackageSystem/PlayMode/HostPlayModeImpl.cs
index 0c818c4..074014d 100644
--- a/Assets/YooAsset/Runtime/PackageSystem/PlayMode/HostPlayModeImpl.cs
+++ b/Assets/YooAsset/Runtime/PackageSystem/PlayMode/HostPlayModeImpl.cs
@@ -284,6 +284,39 @@ namespace YooAsset
return ManifestTools.ConvertToUnpackInfos(downloadList);
}
+
+ ResourceImporterOperation IPlayModeServices.CreateResourceImporterByFilePaths(string[] filePaths, int importerMaxNumber, int failedTryAgain, int timeout)
+ {
+ List importerList = GetImporterListByFilePaths(_activeManifest, filePaths);
+ var operation = new ResourceImporterOperation(importerList, importerMaxNumber, failedTryAgain, timeout);
+ return operation;
+ }
+ private List GetImporterListByFilePaths(PackageManifest manifest, string[] filePaths)
+ {
+ List result = new List();
+ foreach (var filePath in filePaths)
+ {
+ string fileName = System.IO.Path.GetFileName(filePath);
+ if (manifest.TryGetPackageBundleByFileName(fileName, out PackageBundle packageBundle))
+ {
+ // 忽略缓存文件
+ if (IsCachedPackageBundle(packageBundle))
+ continue;
+
+ // 忽略APP资源
+ if (IsBuildinPackageBundle(packageBundle))
+ continue;
+
+ var bundleInfo = ManifestTools.ConvertToImportInfo(packageBundle, filePath);
+ result.Add(bundleInfo);
+ }
+ else
+ {
+ YooLogger.Warning($"Not found package bundle, importer file path : {filePath}");
+ }
+ }
+ return result;
+ }
#endregion
#region IBundleServices接口
diff --git a/Assets/YooAsset/Runtime/PackageSystem/PlayMode/OfflinePlayModeImpl.cs b/Assets/YooAsset/Runtime/PackageSystem/PlayMode/OfflinePlayModeImpl.cs
index fc2cdb3..1c77aa6 100644
--- a/Assets/YooAsset/Runtime/PackageSystem/PlayMode/OfflinePlayModeImpl.cs
+++ b/Assets/YooAsset/Runtime/PackageSystem/PlayMode/OfflinePlayModeImpl.cs
@@ -117,6 +117,35 @@ namespace YooAsset
return ManifestTools.ConvertToUnpackInfos(downloadList);
}
+
+ ResourceImporterOperation IPlayModeServices.CreateResourceImporterByFilePaths(string[] filePaths, int importerMaxNumber, int failedTryAgain, int timeout)
+ {
+ List importerList = GetImporterListByFilePaths(_activeManifest, filePaths);
+ var operation = new ResourceImporterOperation(importerList, importerMaxNumber, failedTryAgain, timeout);
+ return operation;
+ }
+ private List GetImporterListByFilePaths(PackageManifest manifest, string[] filePaths)
+ {
+ List result = new List();
+ foreach (var filePath in filePaths)
+ {
+ string fileName = System.IO.Path.GetFileName(filePath);
+ if (manifest.TryGetPackageBundleByFileName(fileName, out PackageBundle packageBundle))
+ {
+ // 忽略缓存文件
+ if (IsCachedPackageBundle(packageBundle))
+ continue;
+
+ var bundleInfo = ManifestTools.ConvertToImportInfo(packageBundle, filePath);
+ result.Add(bundleInfo);
+ }
+ else
+ {
+ YooLogger.Warning($"Not found package bundle, importer file path : {filePath}");
+ }
+ }
+ return result;
+ }
#endregion
#region IBundleServices接口
diff --git a/Assets/YooAsset/Runtime/PackageSystem/PlayMode/WebPlayModeImpl.cs b/Assets/YooAsset/Runtime/PackageSystem/PlayMode/WebPlayModeImpl.cs
index 2ab2e58..346c6b3 100644
--- a/Assets/YooAsset/Runtime/PackageSystem/PlayMode/WebPlayModeImpl.cs
+++ b/Assets/YooAsset/Runtime/PackageSystem/PlayMode/WebPlayModeImpl.cs
@@ -199,6 +199,11 @@ namespace YooAsset
{
return ResourceUnpackerOperation.CreateEmptyUnpacker(upackingMaxNumber, failedTryAgain, timeout);
}
+
+ ResourceImporterOperation IPlayModeServices.CreateResourceImporterByFilePaths(string[] filePaths, int importerMaxNumber, int failedTryAgain, int timeout)
+ {
+ return ResourceImporterOperation.CreateEmptyImporter(importerMaxNumber, failedTryAgain, timeout);
+ }
#endregion
#region IBundleServices接口
diff --git a/Assets/YooAsset/Runtime/PackageSystem/ResourcePackage.cs b/Assets/YooAsset/Runtime/PackageSystem/ResourcePackage.cs
index f76e8be..24d0f91 100644
--- a/Assets/YooAsset/Runtime/PackageSystem/ResourcePackage.cs
+++ b/Assets/YooAsset/Runtime/PackageSystem/ResourcePackage.cs
@@ -299,6 +299,17 @@ namespace YooAsset
return operation;
}
+ ///
+ /// 获取指定版本的缓存信息
+ ///
+ public GetAllCacheFileInfosOperation GetAllCacheFileInfosAsync(string packageVersion, int timeout = 60)
+ {
+ DebugCheckInitialize();
+ var operation = new GetAllCacheFileInfosOperation(PackageName);
+ OperationSystem.StartOperation(operation);
+ return operation;
+ }
+
///
/// 获取本地包裹的版本信息
///
@@ -335,7 +346,7 @@ namespace YooAsset
{
DebugCheckInitialize();
var persistent = PersistentTools.GetPersistent(PackageName);
- return persistent.BuildinRoot;
+ return persistent.BuildinPackageRoot;
}
///
@@ -345,7 +356,17 @@ namespace YooAsset
{
DebugCheckInitialize();
var persistent = PersistentTools.GetPersistent(PackageName);
- return persistent.SandboxRoot;
+ return persistent.SandboxPackageRoot;
+ }
+
+ ///
+ /// 获取包裹的沙盒文件AB文件的缓存目录
+ ///
+ public string GetPackageSandboxCacheBundleRootDirectory()
+ {
+ DebugCheckInitialize();
+ var persistent = PersistentTools.GetPersistent(PackageName);
+ return persistent.SandboxCacheBundleFilesRoot;
}
///
@@ -1026,6 +1047,21 @@ namespace YooAsset
}
#endregion
+ #region 资源导入
+ ///
+ /// 创建资源导入器
+ /// 注意:资源文件名称必须和资源服务器部署的文件名称一致!
+ ///
+ /// 资源路径列表
+ /// 同时导入的最大文件数
+ /// 导入失败的重试次数
+ public ResourceImporterOperation CreateResourceImporter(string[] filePaths, int importerMaxNumber, int failedTryAgain)
+ {
+ DebugCheckInitialize();
+ return _playModeServices.CreateResourceImporterByFilePaths(filePaths, importerMaxNumber, failedTryAgain, int.MaxValue);
+ }
+ #endregion
+
#region 内部方法
///
/// 是否包含资源文件
diff --git a/Assets/YooAsset/Runtime/Services/Internal/IPlayModeServices.cs b/Assets/YooAsset/Runtime/Services/Internal/IPlayModeServices.cs
index d1be3a0..3d129c3 100644
--- a/Assets/YooAsset/Runtime/Services/Internal/IPlayModeServices.cs
+++ b/Assets/YooAsset/Runtime/Services/Internal/IPlayModeServices.cs
@@ -36,5 +36,8 @@ namespace YooAsset
// 解压相关
ResourceUnpackerOperation CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout);
ResourceUnpackerOperation CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout);
+
+ // 导入相关
+ ResourceImporterOperation CreateResourceImporterByFilePaths(string[] filePaths, int importerMaxNumber, int failedTryAgain, int timeout);
}
}
\ No newline at end of file