Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
hevinci | dc33abde46 | |
hevinci | aae7b08dd1 |
|
@ -79,6 +79,30 @@ namespace YooAsset
|
|||
_isUnloadSafe = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 销毁
|
||||
/// </summary>
|
||||
public void DestroyAll()
|
||||
{
|
||||
foreach (var provider in _providerList)
|
||||
{
|
||||
provider.Destroy();
|
||||
}
|
||||
_providerList.Clear();
|
||||
_providerDic.Clear();
|
||||
|
||||
foreach (var loader in _loaderList)
|
||||
{
|
||||
loader.Destroy(true);
|
||||
}
|
||||
_loaderList.Clear();
|
||||
_loaderDic.Clear();
|
||||
|
||||
ClearSceneHandle();
|
||||
DecryptionServices = null;
|
||||
BundleServices = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源回收(卸载引用计数为零的资源)
|
||||
/// </summary>
|
||||
|
@ -125,12 +149,10 @@ namespace YooAsset
|
|||
{
|
||||
foreach (var provider in _providerList)
|
||||
{
|
||||
provider.WaitForAsyncComplete();
|
||||
provider.Destroy();
|
||||
}
|
||||
foreach (var loader in _loaderList)
|
||||
{
|
||||
loader.WaitForAsyncComplete();
|
||||
loader.Destroy(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -246,7 +246,7 @@ namespace YooAsset
|
|||
var result = CacheSystem.VerifyingRecordFile(MainBundleInfo.Bundle.PackageName, MainBundleInfo.Bundle.CacheGUID);
|
||||
if (result != EVerifyResult.Succeed)
|
||||
{
|
||||
YooLogger.Error($"Found possibly corrupt file ! {MainBundleInfo.Bundle.CacheGUID}");
|
||||
YooLogger.Error($"Found possibly corrupt file ! {MainBundleInfo.Bundle.CacheGUID} Verify result : {result}");
|
||||
CacheSystem.DiscardFile(MainBundleInfo.Bundle.PackageName, MainBundleInfo.Bundle.CacheGUID);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c9fd0b949af8480fa2e882cf65f7b01b
|
||||
timeCreated: 1687234632
|
|
@ -1,90 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
public class ClearTagsCachedRawFilesOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
GetCacheFiles,
|
||||
ClearCacheFiles,
|
||||
Done
|
||||
}
|
||||
|
||||
private ESteps steps;
|
||||
private List<PackageBundle> cachedBundles;
|
||||
private ResourcePackage package;
|
||||
private string[] tags;
|
||||
private int clearTotalCount;
|
||||
|
||||
internal ClearTagsCachedRawFilesOperation(ResourcePackage package, string[] tags)
|
||||
{
|
||||
this.package = package;
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
internal override void Start()
|
||||
{
|
||||
steps = ESteps.GetCacheFiles;
|
||||
}
|
||||
|
||||
internal override void Update()
|
||||
{
|
||||
if (steps == ESteps.None || steps == ESteps.Done)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (steps == ESteps.GetCacheFiles)
|
||||
{
|
||||
var bundles = package.GetCachedTagsRawFiles(tags);
|
||||
cachedBundles = new List<PackageBundle>();
|
||||
foreach (PackageBundle b in bundles)
|
||||
{
|
||||
if (!b.IsRawFile)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (CacheSystem.IsCached(b.PackageName, b.CacheGUID))
|
||||
{
|
||||
cachedBundles.Add(b);
|
||||
}
|
||||
}
|
||||
|
||||
clearTotalCount = cachedBundles.Count;
|
||||
steps = ESteps.ClearCacheFiles;
|
||||
}
|
||||
|
||||
if (steps == ESteps.ClearCacheFiles)
|
||||
{
|
||||
for (var i = cachedBundles.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var b = cachedBundles[i];
|
||||
CacheSystem.DiscardFile(b.PackageName, b.CacheGUID);
|
||||
cachedBundles.RemoveAt(i);
|
||||
if (OperationSystem.IsBusy)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (clearTotalCount == 0)
|
||||
{
|
||||
Progress = 1f;
|
||||
}
|
||||
else
|
||||
{
|
||||
Progress = 1f - (1f * cachedBundles.Count / clearTotalCount);
|
||||
}
|
||||
|
||||
if (cachedBundles.Count == 0)
|
||||
{
|
||||
steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 93d20d548161467fb47833ab204f4651
|
||||
timeCreated: 1687235010
|
|
@ -121,28 +121,5 @@ namespace YooAsset
|
|||
return _activeManifest != null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region MLY
|
||||
|
||||
public List<PackageBundle> GetCachedTagsRawFiles(string[] tags)
|
||||
{
|
||||
List<PackageBundle> result = new List<PackageBundle>(1000);
|
||||
foreach (PackageBundle b in _activeManifest.BundleList)
|
||||
{
|
||||
if (b.HasTag(tags))
|
||||
{
|
||||
result.Add(b);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<PackageBundle> GetNeedDownloadTagsRawFiles(string[] tags)
|
||||
{
|
||||
return new List<PackageBundle>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -344,68 +344,5 @@ namespace YooAsset
|
|||
return _activeManifest != null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region MLY修改
|
||||
|
||||
public List<PackageBundle> GetCachedTagsRawFiles(string[] tags)
|
||||
{
|
||||
return GetCachedTagsBundle(_activeManifest, tags);
|
||||
}
|
||||
|
||||
public List<PackageBundle> GetCachedTagsBundle(PackageManifest manifest,string[] tags)
|
||||
{
|
||||
List<PackageBundle> result = new List<PackageBundle>(1000);
|
||||
foreach (PackageBundle b in manifest.BundleList)
|
||||
{
|
||||
if (IsBuildinPackageBundle(b))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!b.IsRawFile)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (IsCachedPackageBundle(b))
|
||||
{
|
||||
if (b.HasTag(tags))
|
||||
{
|
||||
result.Add(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<PackageBundle> GetNeedDownloadTagsRawFiles(string[] tags)
|
||||
{
|
||||
List<PackageBundle> neetDownloadList = new List<PackageBundle>(200);
|
||||
foreach (PackageBundle bundle in _activeManifest.BundleList)
|
||||
{
|
||||
if (IsCachedPackageBundle(bundle))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (IsBuildinPackageBundle(bundle))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!bundle.HasAnyTags())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (bundle.HasTag(tags))
|
||||
{
|
||||
neetDownloadList.Add(bundle);
|
||||
}
|
||||
}
|
||||
|
||||
return neetDownloadList;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -131,19 +131,5 @@ namespace YooAsset
|
|||
return _activeManifest != null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region MLy
|
||||
|
||||
public List<PackageBundle> GetCachedTagsRawFiles(string[] tags)
|
||||
{
|
||||
return new List<PackageBundle>();
|
||||
}
|
||||
|
||||
public List<PackageBundle> GetNeedDownloadTagsRawFiles(string[] tags)
|
||||
{
|
||||
return new List<PackageBundle>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -62,7 +62,7 @@ namespace YooAsset
|
|||
|
||||
if (_assetSystemImpl != null)
|
||||
{
|
||||
_assetSystemImpl.ForceUnloadAllAssets();
|
||||
_assetSystemImpl.DestroyAll();
|
||||
_assetSystemImpl = null;
|
||||
}
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ namespace YooAsset
|
|||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源信息列表
|
||||
/// </summary>
|
||||
|
@ -839,46 +839,5 @@ namespace YooAsset
|
|||
return data;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region MLY扩展
|
||||
|
||||
public long GetCachedTagsRawFileSize(string[] tags)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
var list = _playModeServices.GetCachedTagsRawFiles(tags);
|
||||
long size = 0;
|
||||
for (var i = 0; i < list.Count; i++)
|
||||
{
|
||||
size += list[i].FileSize;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
internal List<PackageBundle> GetCachedTagsRawFiles(string[] tags)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return _playModeServices.GetCachedTagsRawFiles(tags);
|
||||
}
|
||||
public ClearTagsCachedRawFilesOperation ClearTagsCacheFilesAsync(string[] tags)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
var operation = new ClearTagsCachedRawFilesOperation(this,tags);
|
||||
OperationSystem.StartOperation(operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
public long GetNeedDownloadTagsRawFileSize(string[] tags)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
var list=_playModeServices.GetNeedDownloadTagsRawFiles(tags);
|
||||
long size = 0;
|
||||
foreach (PackageBundle packageBundle in list)
|
||||
{
|
||||
size += packageBundle.FileSize;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -1,6 +1,4 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal interface IPlayModeServices
|
||||
|
@ -38,8 +36,5 @@ namespace YooAsset
|
|||
// 解压相关
|
||||
ResourceUnpackerOperation CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout);
|
||||
ResourceUnpackerOperation CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout);
|
||||
|
||||
List<PackageBundle> GetCachedTagsRawFiles(string[] tags);
|
||||
List<PackageBundle> GetNeedDownloadTagsRawFiles(string[] tags);
|
||||
}
|
||||
}
|
|
@ -414,21 +414,5 @@ namespace YooAsset
|
|||
throw new Exception($"Default package is null. Please use {nameof(YooAssets.SetDefaultPackage)} !");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region MLY
|
||||
|
||||
public static long GetCachedTagsRawFileSize(string[] tags)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.GetCachedTagsRawFileSize(tags);
|
||||
}
|
||||
|
||||
public static ClearTagsCachedRawFilesOperation ClearTagsCacheRawFilesAsync(string[] tags)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.ClearTagsCacheFilesAsync(tags);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -23,6 +23,13 @@ public sealed class StreamingAssetsHelper
|
|||
private static bool _isInit = false;
|
||||
private static readonly HashSet<string> _cacheData = new HashSet<string>();
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public static void Init() { _isInit = true; }
|
||||
public static bool FileExists(string fileName)
|
||||
{
|
||||
return File.Exists(System.IO.Path.Combine(Application.streamingAssetsPath, "BuildinFiles", fileName));
|
||||
}
|
||||
#else
|
||||
/// <summary>
|
||||
/// 初始化
|
||||
/// </summary>
|
||||
|
@ -49,6 +56,7 @@ public sealed class StreamingAssetsHelper
|
|||
|
||||
return _cacheData.Contains(fileName);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "com.tuyoogame.yooasset",
|
||||
"displayName": "YooAsset",
|
||||
"version": "1.4.16005",
|
||||
"version": "1.4.16",
|
||||
"unity": "2019.4",
|
||||
"description": "unity3d resources management system.",
|
||||
"author": {
|
||||
|
|
Loading…
Reference in New Issue