Compare commits
11 Commits
Author | SHA1 | Date |
---|---|---|
Nocye | db81ba8d67 | |
hevinci | dc5086a644 | |
Nocye | 92e385bd73 | |
Nocye | 340a69b251 | |
Nocye | 6f3198a2e1 | |
Nocye | 79a9763555 | |
Nocye | fa111f8d93 | |
Nocye | 693711c23b | |
Nocye | fc2ea03a5e | |
Nocye | 374feaf82d | |
Nocye | 92cba88853 |
|
@ -79,30 +79,6 @@ 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>
|
||||
|
@ -149,10 +125,12 @@ namespace YooAsset
|
|||
{
|
||||
foreach (var provider in _providerList)
|
||||
{
|
||||
provider.WaitForAsyncComplete();
|
||||
provider.Destroy();
|
||||
}
|
||||
foreach (var loader in _loaderList)
|
||||
{
|
||||
loader.WaitForAsyncComplete();
|
||||
loader.Destroy(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c9fd0b949af8480fa2e882cf65f7b01b
|
||||
timeCreated: 1687234632
|
|
@ -0,0 +1,90 @@
|
|||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 93d20d548161467fb47833ab204f4651
|
||||
timeCreated: 1687235010
|
|
@ -121,5 +121,28 @@ 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,5 +344,68 @@ 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,5 +131,19 @@ 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.DestroyAll();
|
||||
_assetSystemImpl.ForceUnloadAllAssets();
|
||||
_assetSystemImpl = null;
|
||||
}
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ namespace YooAsset
|
|||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源信息列表
|
||||
/// </summary>
|
||||
|
@ -839,5 +839,46 @@ 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,4 +1,6 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal interface IPlayModeServices
|
||||
|
@ -36,5 +38,8 @@ 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,5 +414,21 @@ 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
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "com.tuyoogame.yooasset",
|
||||
"displayName": "YooAsset",
|
||||
"version": "1.4.16",
|
||||
"version": "1.4.16005",
|
||||
"unity": "2019.4",
|
||||
"description": "unity3d resources management system.",
|
||||
"author": {
|
||||
|
|
Loading…
Reference in New Issue