mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-15 04:00:16 +00:00
Compare commits
13 Commits
2.2.5-prev
...
2.2.6-prev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bfda5ec952 | ||
|
|
248bdba839 | ||
|
|
75dd3d0e5e | ||
|
|
8944ec0e02 | ||
|
|
069e29ac07 | ||
|
|
942e4bf672 | ||
|
|
dca37a3794 | ||
|
|
f84419b7a6 | ||
|
|
aa3a049985 | ||
|
|
3f8c7bd91f | ||
|
|
11984d6972 | ||
|
|
31b0a3fb54 | ||
|
|
666d0b53a6 |
@@ -2,6 +2,57 @@
|
||||
|
||||
All notable changes to this package will be documented in this file.
|
||||
|
||||
## [2.2.6-preview] - 2024-12-27
|
||||
|
||||
### Improvements
|
||||
|
||||
- 增强了对Steam平台DLC拓展包的支持。
|
||||
|
||||
```csharp
|
||||
// 新增参数关闭Catalog目录查询内置文件的功能
|
||||
var fileSystemParams = CreateDefaultBuildinFileSystemParameters();
|
||||
fileSystemParams .AddParameter(FileSystemParametersDefine.DISABLE_CATALOG_FILE, true);
|
||||
```
|
||||
|
||||
- 资源句柄基类提供了统一的Release方法。
|
||||
|
||||
```csharp
|
||||
public abstract class HandleBase : IEnumerator, IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// 释放资源句柄
|
||||
/// </summary>
|
||||
public void Release();
|
||||
|
||||
/// <summary>
|
||||
/// 释放资源句柄
|
||||
/// </summary>
|
||||
public void Dispose();
|
||||
}
|
||||
```
|
||||
|
||||
- 优化了场景卸载逻辑。
|
||||
|
||||
```csharp
|
||||
//框架内不在区分主场景和附加场景。
|
||||
//场景卸载后自动释放资源句柄。
|
||||
```
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复了Unity2020版本提示的脚本编译错误。
|
||||
- (#417) 修复了DefaultWebServerFileSystem文件系统内Catalog未起效的问题。
|
||||
|
||||
### Added
|
||||
|
||||
- 新增示例文件 GetCacheBundleSizeOperation.cs
|
||||
|
||||
可以获取指定Package的缓存资源总大小。
|
||||
|
||||
### Removed
|
||||
|
||||
- 移除了SceneHandle.IsMainScene()方法。
|
||||
|
||||
## [2.2.5-preview] - 2024-12-25
|
||||
|
||||
依赖的ScriptableBuildPipeline (SBP) 插件库版本切换为1.21.25版本!
|
||||
|
||||
@@ -56,11 +56,7 @@ namespace YooAsset.Editor
|
||||
public string EncryptedFilePath { set; get; }
|
||||
#endregion
|
||||
|
||||
#if UNITY_2020_3_OR_NEWER
|
||||
private readonly HashSet<string> _assetPaths = new HashSet<string>(1000);
|
||||
#else
|
||||
private readonly HashSet<string> _assetPaths = new HashSet<string>();
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// 参与构建的资源列表
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace YooAsset.Editor
|
||||
buildReport.Summary.BuildSeconds = BuildRunner.TotalSeconds;
|
||||
buildReport.Summary.BuildTarget = buildParameters.BuildTarget;
|
||||
buildReport.Summary.BuildPipeline = buildParameters.BuildPipeline;
|
||||
buildReport.Summary.BuildBundleType = buildParameters.BuildBundleType;
|
||||
buildReport.Summary.BuildPackageName = buildParameters.PackageName;
|
||||
buildReport.Summary.BuildPackageVersion = buildParameters.PackageVersion;
|
||||
buildReport.Summary.BuildPackageNote = buildParameters.PackageNote;
|
||||
|
||||
@@ -38,6 +38,11 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public string BuildPipeline;
|
||||
|
||||
/// <summary>
|
||||
/// 构建的资源包类型
|
||||
/// </summary>
|
||||
public int BuildBundleType;
|
||||
|
||||
/// <summary>
|
||||
/// 构建包裹名称
|
||||
/// </summary>
|
||||
|
||||
@@ -62,6 +62,7 @@ namespace YooAsset.Editor
|
||||
_items.Add(new ItemWrapper("Build Seconds", ConvertTime(buildReport.Summary.BuildSeconds)));
|
||||
_items.Add(new ItemWrapper("Build Target", $"{buildReport.Summary.BuildTarget}"));
|
||||
_items.Add(new ItemWrapper("Build Pipeline", $"{buildReport.Summary.BuildPipeline}"));
|
||||
_items.Add(new ItemWrapper("Build Bundle Type", buildReport.Summary.BuildBundleType.ToString()));
|
||||
_items.Add(new ItemWrapper("Package Name", buildReport.Summary.BuildPackageName));
|
||||
_items.Add(new ItemWrapper("Package Version", buildReport.Summary.BuildPackageVersion));
|
||||
_items.Add(new ItemWrapper("Package Note", buildReport.Summary.BuildPackageNote));
|
||||
|
||||
@@ -63,6 +63,11 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public bool AppendFileExtension { private set; get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:禁用Catalog目录查询文件
|
||||
/// </summary>
|
||||
public bool DisableCatalogFile { private set; get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:解密方法类
|
||||
/// </summary>
|
||||
@@ -138,6 +143,10 @@ namespace YooAsset
|
||||
{
|
||||
AppendFileExtension = (bool)value;
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.DISABLE_CATALOG_FILE)
|
||||
{
|
||||
DisableCatalogFile = (bool)value;
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.DECRYPTION_SERVICES)
|
||||
{
|
||||
DecryptionServices = (IDecryptionServices)value;
|
||||
@@ -172,10 +181,14 @@ namespace YooAsset
|
||||
|
||||
public virtual bool Belong(PackageBundle bundle)
|
||||
{
|
||||
if (DisableCatalogFile)
|
||||
return true;
|
||||
return _wrappers.ContainsKey(bundle.BundleGUID);
|
||||
}
|
||||
public virtual bool Exists(PackageBundle bundle)
|
||||
{
|
||||
if (DisableCatalogFile)
|
||||
return true;
|
||||
return _wrappers.ContainsKey(bundle.BundleGUID);
|
||||
}
|
||||
public virtual bool NeedDownload(PackageBundle bundle)
|
||||
@@ -306,7 +319,7 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 记录文件信息
|
||||
/// </summary>
|
||||
public bool RecordFile(string bundleGUID, FileWrapper wrapper)
|
||||
public bool RecordCatalogFile(string bundleGUID, FileWrapper wrapper)
|
||||
{
|
||||
if (_wrappers.ContainsKey(bundleGUID))
|
||||
{
|
||||
|
||||
@@ -48,7 +48,15 @@ namespace YooAsset
|
||||
|
||||
if (_initUnpackFIleSystemOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.LoadCatalogFile;
|
||||
if (_fileSystem.DisableCatalogFile)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.LoadCatalogFile;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace YooAsset
|
||||
foreach (var wrapper in catalog.Wrappers)
|
||||
{
|
||||
var fileWrapper = new DefaultBuildinFileSystem.FileWrapper(wrapper.FileName);
|
||||
_fileSystem.RecordFile(wrapper.BundleGUID, fileWrapper);
|
||||
_fileSystem.RecordCatalogFile(wrapper.BundleGUID, fileWrapper);
|
||||
}
|
||||
|
||||
YooLogger.Log($"Package '{_fileSystem.PackageName}' buildin catalog files count : {catalog.Wrappers.Count}");
|
||||
|
||||
@@ -133,11 +133,11 @@ namespace YooAsset
|
||||
|
||||
public virtual bool Belong(PackageBundle bundle)
|
||||
{
|
||||
return true;
|
||||
return _wrappers.ContainsKey(bundle.BundleGUID);
|
||||
}
|
||||
public virtual bool Exists(PackageBundle bundle)
|
||||
{
|
||||
return true;
|
||||
return _wrappers.ContainsKey(bundle.BundleGUID);
|
||||
}
|
||||
public virtual bool NeedDownload(PackageBundle bundle)
|
||||
{
|
||||
@@ -201,9 +201,9 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 记录文件信息
|
||||
/// 记录内置文件信息
|
||||
/// </summary>
|
||||
public bool RecordFile(string bundleGUID, FileWrapper wrapper)
|
||||
public bool RecordCatalogFile(string bundleGUID, FileWrapper wrapper)
|
||||
{
|
||||
if (_wrappers.ContainsKey(bundleGUID))
|
||||
{
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace YooAsset
|
||||
foreach (var wrapper in catalog.Wrappers)
|
||||
{
|
||||
var fileWrapper = new DefaultWebServerFileSystem.FileWrapper(wrapper.FileName);
|
||||
_fileSystem.RecordFile(wrapper.BundleGUID, fileWrapper);
|
||||
_fileSystem.RecordCatalogFile(wrapper.BundleGUID, fileWrapper);
|
||||
}
|
||||
|
||||
YooLogger.Log($"Package '{_fileSystem.PackageName}' catalog files count : {catalog.Wrappers.Count}");
|
||||
|
||||
140
Assets/YooAsset/Runtime/FileSystem/FileSystemParameters.cs
Normal file
140
Assets/YooAsset/Runtime/FileSystem/FileSystemParameters.cs
Normal file
@@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件系统参数
|
||||
/// </summary>
|
||||
public class FileSystemParameters
|
||||
{
|
||||
internal readonly Dictionary<string, object> CreateParameters = new Dictionary<string, object>(100);
|
||||
|
||||
/// <summary>
|
||||
/// 文件系统类
|
||||
/// 格式: "namespace.class,assembly"
|
||||
/// 格式: "命名空间.类型名,程序集"
|
||||
/// </summary>
|
||||
public string FileSystemClass { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件系统的根目录
|
||||
/// </summary>
|
||||
public string RootDirectory { private set; get; }
|
||||
|
||||
|
||||
public FileSystemParameters(string fileSystemClass, string rootDirectory)
|
||||
{
|
||||
FileSystemClass = fileSystemClass;
|
||||
RootDirectory = rootDirectory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加自定义参数
|
||||
/// </summary>
|
||||
public void AddParameter(string name, object value)
|
||||
{
|
||||
CreateParameters.Add(name, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建文件系统
|
||||
/// </summary>
|
||||
internal IFileSystem CreateFileSystem(string packageName)
|
||||
{
|
||||
YooLogger.Log($"The package {packageName} create file system : {FileSystemClass}");
|
||||
|
||||
Type classType = Type.GetType(FileSystemClass);
|
||||
if (classType == null)
|
||||
{
|
||||
YooLogger.Error($"Can not found file system class type {FileSystemClass}");
|
||||
return null;
|
||||
}
|
||||
|
||||
var instance = (IFileSystem)System.Activator.CreateInstance(classType, true);
|
||||
if (instance == null)
|
||||
{
|
||||
YooLogger.Error($"Failed to create file system instance {FileSystemClass}");
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach (var param in CreateParameters)
|
||||
{
|
||||
instance.SetParameter(param.Key, param.Value);
|
||||
}
|
||||
instance.OnCreate(packageName, RootDirectory);
|
||||
return instance;
|
||||
}
|
||||
|
||||
#region 创建默认的文件系统类
|
||||
/// <summary>
|
||||
/// 创建默认的编辑器文件系统参数
|
||||
/// <param name="simulateBuildResult">模拟构建结果</param>
|
||||
/// </summary>
|
||||
public static FileSystemParameters CreateDefaultEditorFileSystemParameters(EditorSimulateBuildResult simulateBuildResult)
|
||||
{
|
||||
string fileSystemClass = typeof(DefaultEditorFileSystem).FullName;
|
||||
var fileSystemParams = new FileSystemParameters(fileSystemClass, simulateBuildResult.PackageRootDirectory);
|
||||
return fileSystemParams;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建默认的内置文件系统参数
|
||||
/// </summary>
|
||||
/// <param name="decryptionServices">加密文件解密服务类</param>
|
||||
/// <param name="verifyLevel">缓存文件的校验等级</param>
|
||||
/// <param name="rootDirectory">内置文件的根路径</param>
|
||||
public static FileSystemParameters CreateDefaultBuildinFileSystemParameters(IDecryptionServices decryptionServices = null, EFileVerifyLevel verifyLevel = EFileVerifyLevel.Middle, string rootDirectory = null)
|
||||
{
|
||||
string fileSystemClass = typeof(DefaultBuildinFileSystem).FullName;
|
||||
var fileSystemParams = new FileSystemParameters(fileSystemClass, rootDirectory);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, decryptionServices);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.FILE_VERIFY_LEVEL, verifyLevel);
|
||||
return fileSystemParams;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建默认的缓存文件系统参数
|
||||
/// </summary>
|
||||
/// <param name="remoteServices">远端资源地址查询服务类</param>
|
||||
/// <param name="decryptionServices">加密文件解密服务类</param>
|
||||
/// <param name="verifyLevel">缓存文件的校验等级</param>
|
||||
/// <param name="rootDirectory">文件系统的根目录</param>
|
||||
public static FileSystemParameters CreateDefaultCacheFileSystemParameters(IRemoteServices remoteServices, IDecryptionServices decryptionServices = null, EFileVerifyLevel verifyLevel = EFileVerifyLevel.Middle, string rootDirectory = null)
|
||||
{
|
||||
string fileSystemClass = typeof(DefaultCacheFileSystem).FullName;
|
||||
var fileSystemParams = new FileSystemParameters(fileSystemClass, rootDirectory);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, decryptionServices);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.FILE_VERIFY_LEVEL, verifyLevel);
|
||||
return fileSystemParams;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建默认的WebServer文件系统参数
|
||||
/// </summary>
|
||||
/// <param name="disableUnityWebCache">禁用Unity的网络缓存</param>
|
||||
public static FileSystemParameters CreateDefaultWebServerFileSystemParameters(bool disableUnityWebCache = false)
|
||||
{
|
||||
string fileSystemClass = typeof(DefaultWebServerFileSystem).FullName;
|
||||
var fileSystemParams = new FileSystemParameters(fileSystemClass, null);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.DISABLE_UNITY_WEB_CACHE, disableUnityWebCache);
|
||||
return fileSystemParams;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建默认的WebRemote文件系统参数
|
||||
/// </summary>
|
||||
/// <param name="remoteServices">远端资源地址查询服务类</param>
|
||||
/// <param name="disableUnityWebCache">禁用Unity的网络缓存</param>
|
||||
public static FileSystemParameters CreateDefaultWebRemoteFileSystemParameters(IRemoteServices remoteServices, bool disableUnityWebCache = false)
|
||||
{
|
||||
string fileSystemClass = typeof(DefaultWebServerFileSystem).FullName;
|
||||
var fileSystemParams = new FileSystemParameters(fileSystemClass, null);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.DISABLE_UNITY_WEB_CACHE, disableUnityWebCache);
|
||||
return fileSystemParams;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6ce5a2677e1696d488c3b883fa915ae0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -7,6 +7,7 @@ namespace YooAsset
|
||||
public const string REMOTE_SERVICES = "REMOTE_SERVICES";
|
||||
public const string DECRYPTION_SERVICES = "DECRYPTION_SERVICES";
|
||||
public const string APPEND_FILE_EXTENSION = "APPEND_FILE_EXTENSION";
|
||||
public const string DISABLE_CATALOG_FILE = "DISABLE_CATALOG_FILE";
|
||||
public const string DISABLE_UNITY_WEB_CACHE = "DISABLE_UNITY_WEB_CACHE";
|
||||
public const string DOWNLOAD_MAX_CONCURRENCY = "DOWNLOAD_MAX_CONCURRENCY";
|
||||
public const string DOWNLOAD_MAX_REQUEST_PER_FRAME = "DOWNLOAD_MAX_REQUEST_PER_FRAME";
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
@@ -29,111 +27,6 @@ namespace YooAsset
|
||||
WebPlayMode,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 文件系统参数
|
||||
/// </summary>
|
||||
public class FileSystemParameters
|
||||
{
|
||||
internal Dictionary<string, object> CreateParameters = new Dictionary<string, object>();
|
||||
|
||||
/// <summary>
|
||||
/// 文件系统类
|
||||
/// 格式: "namespace.class,assembly"
|
||||
/// 格式: "命名空间.类型名,程序集"
|
||||
/// </summary>
|
||||
public string FileSystemClass { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件系统的根目录
|
||||
/// </summary>
|
||||
public string RootDirectory { private set; get; }
|
||||
|
||||
|
||||
public FileSystemParameters(string fileSystemClass, string rootDirectory)
|
||||
{
|
||||
FileSystemClass = fileSystemClass;
|
||||
RootDirectory = rootDirectory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加自定义参数
|
||||
/// </summary>
|
||||
public void AddParameter(string name, object value)
|
||||
{
|
||||
CreateParameters.Add(name, value);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 创建默认的编辑器文件系统参数
|
||||
/// <param name="simulateBuildResult">模拟构建结果</param>
|
||||
/// </summary>
|
||||
public static FileSystemParameters CreateDefaultEditorFileSystemParameters(EditorSimulateBuildResult simulateBuildResult)
|
||||
{
|
||||
string fileSystemClass = typeof(DefaultEditorFileSystem).FullName;
|
||||
var fileSystemParams = new FileSystemParameters(fileSystemClass, simulateBuildResult.PackageRootDirectory);
|
||||
return fileSystemParams;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建默认的内置文件系统参数
|
||||
/// </summary>
|
||||
/// <param name="decryptionServices">加密文件解密服务类</param>
|
||||
/// <param name="verifyLevel">缓存文件的校验等级</param>
|
||||
/// <param name="rootDirectory">内置文件的根路径</param>
|
||||
public static FileSystemParameters CreateDefaultBuildinFileSystemParameters(IDecryptionServices decryptionServices = null, EFileVerifyLevel verifyLevel = EFileVerifyLevel.Middle, string rootDirectory = null)
|
||||
{
|
||||
string fileSystemClass = typeof(DefaultBuildinFileSystem).FullName;
|
||||
var fileSystemParams = new FileSystemParameters(fileSystemClass, rootDirectory);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, decryptionServices);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.FILE_VERIFY_LEVEL, verifyLevel);
|
||||
return fileSystemParams;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建默认的缓存文件系统参数
|
||||
/// </summary>
|
||||
/// <param name="remoteServices">远端资源地址查询服务类</param>
|
||||
/// <param name="decryptionServices">加密文件解密服务类</param>
|
||||
/// <param name="verifyLevel">缓存文件的校验等级</param>
|
||||
/// <param name="rootDirectory">文件系统的根目录</param>
|
||||
public static FileSystemParameters CreateDefaultCacheFileSystemParameters(IRemoteServices remoteServices, IDecryptionServices decryptionServices = null, EFileVerifyLevel verifyLevel = EFileVerifyLevel.Middle, string rootDirectory = null)
|
||||
{
|
||||
string fileSystemClass = typeof(DefaultCacheFileSystem).FullName;
|
||||
var fileSystemParams = new FileSystemParameters(fileSystemClass, rootDirectory);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, decryptionServices);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.FILE_VERIFY_LEVEL, verifyLevel);
|
||||
return fileSystemParams;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建默认的WebServer文件系统参数
|
||||
/// </summary>
|
||||
/// <param name="disableUnityWebCache">禁用Unity的网络缓存</param>
|
||||
public static FileSystemParameters CreateDefaultWebServerFileSystemParameters(bool disableUnityWebCache = false)
|
||||
{
|
||||
string fileSystemClass = typeof(DefaultWebServerFileSystem).FullName;
|
||||
var fileSystemParams = new FileSystemParameters(fileSystemClass, null);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.DISABLE_UNITY_WEB_CACHE, disableUnityWebCache);
|
||||
return fileSystemParams;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建默认的WebRemote文件系统参数
|
||||
/// </summary>
|
||||
/// <param name="remoteServices">远端资源地址查询服务类</param>
|
||||
/// <param name="disableUnityWebCache">禁用Unity的网络缓存</param>
|
||||
public static FileSystemParameters CreateDefaultWebRemoteFileSystemParameters(IRemoteServices remoteServices, bool disableUnityWebCache = false)
|
||||
{
|
||||
string fileSystemClass = typeof(DefaultWebServerFileSystem).FullName;
|
||||
var fileSystemParams = new FileSystemParameters(fileSystemClass, null);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.DISABLE_UNITY_WEB_CACHE, disableUnityWebCache);
|
||||
return fileSystemParams;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化参数
|
||||
/// </summary>
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
public sealed class AllAssetsHandle : HandleBase, IDisposable
|
||||
public sealed class AllAssetsHandle : HandleBase
|
||||
{
|
||||
private System.Action<AllAssetsHandle> _callback;
|
||||
|
||||
@@ -47,23 +46,6 @@ namespace YooAsset
|
||||
Provider.WaitForAsyncComplete();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放资源句柄
|
||||
/// </summary>
|
||||
public void Release()
|
||||
{
|
||||
this.ReleaseInternal();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放资源句柄
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
this.ReleaseInternal();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 子资源对象集合
|
||||
/// </summary>
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
public sealed class AssetHandle : HandleBase, IDisposable
|
||||
public sealed class AssetHandle : HandleBase
|
||||
{
|
||||
private System.Action<AssetHandle> _callback;
|
||||
|
||||
@@ -48,22 +46,6 @@ namespace YooAsset
|
||||
Provider.WaitForAsyncComplete();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放资源句柄
|
||||
/// </summary>
|
||||
public void Release()
|
||||
{
|
||||
this.ReleaseInternal();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放资源句柄
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
this.ReleaseInternal();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 资源对象
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.Collections;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
public abstract class HandleBase : IEnumerator
|
||||
public abstract class HandleBase : IEnumerator, IDisposable
|
||||
{
|
||||
private readonly AssetInfo _assetInfo;
|
||||
internal ProviderOperation Provider { private set; get; }
|
||||
@@ -15,6 +15,25 @@ namespace YooAsset
|
||||
}
|
||||
internal abstract void InvokeCallback();
|
||||
|
||||
/// <summary>
|
||||
/// 释放资源句柄
|
||||
/// </summary>
|
||||
public void Release()
|
||||
{
|
||||
if (IsValidWithWarning == false)
|
||||
return;
|
||||
Provider.ReleaseHandle(this);
|
||||
Provider = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放资源句柄
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
this.Release();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源信息
|
||||
/// </summary>
|
||||
@@ -121,17 +140,6 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放句柄
|
||||
/// </summary>
|
||||
internal void ReleaseInternal()
|
||||
{
|
||||
if (IsValidWithWarning == false)
|
||||
return;
|
||||
Provider.ReleaseHandle(this);
|
||||
Provider = null;
|
||||
}
|
||||
|
||||
#region 异步操作相关
|
||||
/// <summary>
|
||||
/// 异步操作任务
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
public class RawFileHandle : HandleBase, IDisposable
|
||||
public class RawFileHandle : HandleBase
|
||||
{
|
||||
private System.Action<RawFileHandle> _callback;
|
||||
|
||||
@@ -48,22 +45,6 @@ namespace YooAsset
|
||||
Provider.WaitForAsyncComplete();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放资源句柄
|
||||
/// </summary>
|
||||
public void Release()
|
||||
{
|
||||
this.ReleaseInternal();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放资源句柄
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
this.ReleaseInternal();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取原生文件的二进制数据
|
||||
|
||||
@@ -112,25 +112,6 @@ namespace YooAsset
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否为主场景
|
||||
/// </summary>
|
||||
public bool IsMainScene()
|
||||
{
|
||||
if (IsValidWithWarning == false)
|
||||
return false;
|
||||
|
||||
if (Provider is SceneProvider)
|
||||
{
|
||||
var temp = Provider as SceneProvider;
|
||||
return temp.SceneMode == LoadSceneMode.Single;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步卸载子场景
|
||||
/// </summary>
|
||||
@@ -147,17 +128,6 @@ namespace YooAsset
|
||||
return operation;
|
||||
}
|
||||
|
||||
// 如果是主场景
|
||||
if (IsMainScene())
|
||||
{
|
||||
string error = $"Cannot unload main scene. Use {nameof(YooAssets.LoadSceneAsync)} method to change the main scene !";
|
||||
YooLogger.Error(error);
|
||||
var operation = new UnloadSceneOperation(error);
|
||||
OperationSystem.StartOperation(packageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
// 卸载子场景
|
||||
// 注意:如果场景正在加载过程,必须等待加载完成后才可以卸载该场景。
|
||||
{
|
||||
var operation = new UnloadSceneOperation(Provider);
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
public sealed class SubAssetsHandle : HandleBase, IDisposable
|
||||
public sealed class SubAssetsHandle : HandleBase
|
||||
{
|
||||
private System.Action<SubAssetsHandle> _callback;
|
||||
|
||||
@@ -47,22 +46,6 @@ namespace YooAsset
|
||||
Provider.WaitForAsyncComplete();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放资源句柄
|
||||
/// </summary>
|
||||
public void Release()
|
||||
{
|
||||
this.ReleaseInternal();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放资源句柄
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
this.ReleaseInternal();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 子资源对象集合
|
||||
@@ -106,14 +89,14 @@ namespace YooAsset
|
||||
if (IsValidWithWarning == false)
|
||||
return null;
|
||||
|
||||
List<TObject> ret = new List<TObject>(Provider.SubAssetObjects.Length);
|
||||
List<TObject> result = new List<TObject>(Provider.SubAssetObjects.Length);
|
||||
foreach (var assetObject in Provider.SubAssetObjects)
|
||||
{
|
||||
var retObject = assetObject as TObject;
|
||||
if (retObject != null)
|
||||
ret.Add(retObject);
|
||||
result.Add(retObject);
|
||||
}
|
||||
return ret.ToArray();
|
||||
return result.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,6 +58,9 @@ namespace YooAsset
|
||||
var loaderDic = _resManager._loaderDic;
|
||||
var providerDic = _resManager._providerDic;
|
||||
|
||||
// 清空所有场景句柄
|
||||
_resManager._sceneHandles.Clear();
|
||||
|
||||
// 释放所有资源句柄
|
||||
foreach (var provider in providerDic.Values)
|
||||
{
|
||||
@@ -79,7 +82,6 @@ namespace YooAsset
|
||||
// 清空数据
|
||||
providerDic.Clear();
|
||||
loaderDic.Clear();
|
||||
_resManager.ClearSceneHandle();
|
||||
|
||||
// 注意:调用底层接口释放所有资源
|
||||
Resources.UnloadUnusedAssets();
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace YooAsset
|
||||
{
|
||||
None,
|
||||
CheckError,
|
||||
PrepareDone,
|
||||
WaitDone,
|
||||
UnLoadScene,
|
||||
Done,
|
||||
}
|
||||
@@ -61,10 +61,10 @@ namespace YooAsset
|
||||
return;
|
||||
}
|
||||
|
||||
_steps = ESteps.PrepareDone;
|
||||
_steps = ESteps.WaitDone;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.PrepareDone)
|
||||
if (_steps == ESteps.WaitDone)
|
||||
{
|
||||
if (_provider.IsDone == false)
|
||||
return;
|
||||
@@ -93,14 +93,19 @@ namespace YooAsset
|
||||
if (_asyncOp == null)
|
||||
{
|
||||
_asyncOp = SceneManager.UnloadSceneAsync(_provider.SceneObject);
|
||||
_provider.ResourceMgr.UnloadSubScene(_provider.SceneName);
|
||||
if (_asyncOp == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Unload scene failed, see the console logs !";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Progress = _asyncOp.progress;
|
||||
if (_asyncOp.isDone == false)
|
||||
return;
|
||||
|
||||
_provider.ResourceMgr.TryUnloadUnusedAsset(_provider.MainAssetInfo);
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
|
||||
@@ -20,11 +20,6 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public string ProviderGUID { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 所属资源系统
|
||||
/// </summary>
|
||||
public ResourceManager ResourceMgr { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源信息
|
||||
/// </summary>
|
||||
@@ -79,7 +74,6 @@ namespace YooAsset
|
||||
|
||||
public ProviderOperation(ResourceManager manager, string providerGUID, AssetInfo assetInfo)
|
||||
{
|
||||
ResourceMgr = manager;
|
||||
ProviderGUID = providerGUID;
|
||||
MainAssetInfo = assetInfo;
|
||||
|
||||
@@ -245,7 +239,7 @@ namespace YooAsset
|
||||
for (int i = _handles.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var handle = _handles[i];
|
||||
handle.ReleaseInternal();
|
||||
handle.Release();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,17 +12,6 @@ namespace YooAsset
|
||||
private bool _suspendLoad;
|
||||
private FSLoadSceneOperation _loadSceneOp;
|
||||
|
||||
/// <summary>
|
||||
/// 场景加载模式
|
||||
/// </summary>
|
||||
public LoadSceneMode SceneMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return _loadParams.loadSceneMode;
|
||||
}
|
||||
}
|
||||
|
||||
public SceneProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo, LoadSceneParameters loadParams, bool suspendLoad) : base(manager, providerGUID, assetInfo)
|
||||
{
|
||||
_loadParams = loadParams;
|
||||
|
||||
@@ -9,12 +9,10 @@ namespace YooAsset
|
||||
{
|
||||
internal class ResourceManager
|
||||
{
|
||||
// 全局场景句柄集合
|
||||
private readonly static Dictionary<string, SceneHandle> _sceneHandles = new Dictionary<string, SceneHandle>(100);
|
||||
private static long _sceneCreateCount = 0;
|
||||
|
||||
internal readonly Dictionary<string, ProviderOperation> _providerDic = new Dictionary<string, ProviderOperation>(5000);
|
||||
internal readonly Dictionary<string, LoadBundleFileOperation> _loaderDic = new Dictionary<string, LoadBundleFileOperation>(5000);
|
||||
internal readonly List<SceneHandle> _sceneHandles = new List<SceneHandle>(100);
|
||||
private long _sceneCreateIndex = 0;
|
||||
private IBundleQuery _bundleQuery;
|
||||
|
||||
/// <summary>
|
||||
@@ -34,6 +32,15 @@ namespace YooAsset
|
||||
public void Initialize(InitializeParameters initializeParameters, IBundleQuery bundleServices)
|
||||
{
|
||||
_bundleQuery = bundleServices;
|
||||
SceneManager.sceneUnloaded += OnSceneUnloaded;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 销毁管理器
|
||||
/// </summary>
|
||||
public void Destroy()
|
||||
{
|
||||
SceneManager.sceneUnloaded -= OnSceneUnloaded;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -93,14 +100,8 @@ namespace YooAsset
|
||||
return completedProvider.CreateHandle<SceneHandle>();
|
||||
}
|
||||
|
||||
// 如果加载的是主场景,则卸载所有缓存的场景
|
||||
if (loadSceneParams.loadSceneMode == LoadSceneMode.Single)
|
||||
{
|
||||
UnloadAllScene();
|
||||
}
|
||||
|
||||
// 注意:同一个场景的ProviderGUID每次加载都会变化
|
||||
string providerGUID = $"{assetInfo.GUID}-{++_sceneCreateCount}";
|
||||
string providerGUID = $"{assetInfo.GUID}-{++_sceneCreateIndex}";
|
||||
ProviderOperation provider;
|
||||
{
|
||||
provider = new SceneProvider(this, providerGUID, assetInfo, loadSceneParams, suspendLoad);
|
||||
@@ -112,7 +113,7 @@ namespace YooAsset
|
||||
provider.Priority = priority;
|
||||
var handle = provider.CreateHandle<SceneHandle>();
|
||||
handle.PackageName = PackageName;
|
||||
_sceneHandles.Add(providerGUID, handle);
|
||||
_sceneHandles.Add(handle);
|
||||
return handle;
|
||||
}
|
||||
|
||||
@@ -224,56 +225,6 @@ namespace YooAsset
|
||||
return provider.CreateHandle<RawFileHandle>();
|
||||
}
|
||||
|
||||
|
||||
internal void UnloadSubScene(string sceneName)
|
||||
{
|
||||
List<string> removeKeys = new List<string>();
|
||||
foreach (var valuePair in _sceneHandles)
|
||||
{
|
||||
var sceneHandle = valuePair.Value;
|
||||
if (sceneHandle.SceneName == sceneName)
|
||||
{
|
||||
// 释放子场景句柄
|
||||
sceneHandle.ReleaseInternal();
|
||||
removeKeys.Add(valuePair.Key);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (string key in removeKeys)
|
||||
{
|
||||
_sceneHandles.Remove(key);
|
||||
}
|
||||
}
|
||||
internal void UnloadAllScene()
|
||||
{
|
||||
// 释放所有场景句柄
|
||||
foreach (var valuePair in _sceneHandles)
|
||||
{
|
||||
valuePair.Value.ReleaseInternal();
|
||||
}
|
||||
_sceneHandles.Clear();
|
||||
}
|
||||
internal void ClearSceneHandle()
|
||||
{
|
||||
// 释放资源包下的所有场景
|
||||
if (_bundleQuery.ManifestValid())
|
||||
{
|
||||
string packageName = PackageName;
|
||||
List<string> removeList = new List<string>();
|
||||
foreach (var valuePair in _sceneHandles)
|
||||
{
|
||||
if (valuePair.Value.PackageName == packageName)
|
||||
{
|
||||
removeList.Add(valuePair.Key);
|
||||
}
|
||||
}
|
||||
foreach (var key in removeList)
|
||||
{
|
||||
_sceneHandles.Remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal LoadBundleFileOperation CreateMainBundleFileLoader(AssetInfo assetInfo)
|
||||
{
|
||||
BundleInfo bundleInfo = _bundleQuery.GetMainBundleInfo(assetInfo);
|
||||
@@ -330,6 +281,25 @@ namespace YooAsset
|
||||
else
|
||||
return null;
|
||||
}
|
||||
private void OnSceneUnloaded(Scene scene)
|
||||
{
|
||||
List<SceneHandle> removeList = new List<SceneHandle>();
|
||||
foreach (var sceneHandle in _sceneHandles)
|
||||
{
|
||||
if (sceneHandle.IsValid)
|
||||
{
|
||||
if (sceneHandle.SceneObject == scene)
|
||||
{
|
||||
sceneHandle.Release();
|
||||
removeList.Add(sceneHandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var sceneHandle in removeList)
|
||||
{
|
||||
_sceneHandles.Remove(sceneHandle);
|
||||
}
|
||||
}
|
||||
|
||||
#region 调试信息
|
||||
internal List<DebugProviderInfo> GetDebugReportInfos()
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace YooAsset
|
||||
return;
|
||||
}
|
||||
|
||||
_impl.EditorFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.EditorFileSystemParameters);
|
||||
_impl.EditorFileSystem = _parameters.EditorFileSystemParameters.CreateFileSystem(_impl.PackageName);
|
||||
if (_impl.EditorFileSystem == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
@@ -127,7 +127,7 @@ namespace YooAsset
|
||||
return;
|
||||
}
|
||||
|
||||
_impl.BuildinFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.BuildinFileSystemParameters);
|
||||
_impl.BuildinFileSystem = _parameters.BuildinFileSystemParameters.CreateFileSystem(_impl.PackageName);
|
||||
if (_impl.BuildinFileSystem == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
@@ -206,7 +206,7 @@ namespace YooAsset
|
||||
return;
|
||||
}
|
||||
|
||||
_impl.BuildinFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.BuildinFileSystemParameters);
|
||||
_impl.BuildinFileSystem = _parameters.BuildinFileSystemParameters.CreateFileSystem(_impl.PackageName);
|
||||
if (_impl.BuildinFileSystem == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
@@ -249,7 +249,7 @@ namespace YooAsset
|
||||
return;
|
||||
}
|
||||
|
||||
_impl.CacheFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.CacheFileSystemParameters);
|
||||
_impl.CacheFileSystem = _parameters.CacheFileSystemParameters.CreateFileSystem(_impl.PackageName);
|
||||
if (_impl.CacheFileSystem == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
@@ -329,7 +329,7 @@ namespace YooAsset
|
||||
return;
|
||||
}
|
||||
|
||||
_impl.WebServerFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.WebServerFileSystemParameters);
|
||||
_impl.WebServerFileSystem = _parameters.WebServerFileSystemParameters.CreateFileSystem(_impl.PackageName);
|
||||
if (_impl.WebServerFileSystem == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
@@ -370,7 +370,7 @@ namespace YooAsset
|
||||
return;
|
||||
}
|
||||
|
||||
_impl.WebRemoteFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.WebRemoteFileSystemParameters);
|
||||
_impl.WebRemoteFileSystem = _parameters.WebRemoteFileSystemParameters.CreateFileSystem(_impl.PackageName);
|
||||
if (_impl.WebRemoteFileSystem == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
|
||||
@@ -5,32 +5,6 @@ namespace YooAsset
|
||||
{
|
||||
internal class PlayModeHelper
|
||||
{
|
||||
public static IFileSystem CreateFileSystem(string packageName, FileSystemParameters parameters)
|
||||
{
|
||||
YooLogger.Log($"The package {packageName} create file system : {parameters.FileSystemClass}");
|
||||
|
||||
Type classType = Type.GetType(parameters.FileSystemClass);
|
||||
if (classType == null)
|
||||
{
|
||||
YooLogger.Error($"Can not found file system class type {parameters.FileSystemClass}");
|
||||
return null;
|
||||
}
|
||||
|
||||
var instance = (IFileSystem)System.Activator.CreateInstance(classType, true);
|
||||
if (instance == null)
|
||||
{
|
||||
YooLogger.Error($"Failed to create file system instance {parameters.FileSystemClass}");
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach (var param in parameters.CreateParameters)
|
||||
{
|
||||
instance.SetParameter(param.Key, param.Value);
|
||||
}
|
||||
instance.OnCreate(packageName, parameters.RootDirectory);
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static List<BundleInfo> GetDownloadListByAll(PackageManifest manifest, IFileSystem fileSystemA = null, IFileSystem fileSystemB = null, IFileSystem fileSystemC = null)
|
||||
{
|
||||
List<BundleInfo> result = new List<BundleInfo>(1000);
|
||||
|
||||
@@ -57,7 +57,13 @@ namespace YooAsset
|
||||
_initializeError = string.Empty;
|
||||
_initializeStatus = EOperationStatus.None;
|
||||
|
||||
_resourceManager = null;
|
||||
// 销毁资源管理器
|
||||
if (_resourceManager != null)
|
||||
{
|
||||
_resourceManager.Destroy();
|
||||
_resourceManager = null;
|
||||
}
|
||||
|
||||
_bundleQuery = null;
|
||||
_playModeImpl = null;
|
||||
}
|
||||
@@ -74,6 +80,13 @@ namespace YooAsset
|
||||
// 检测初始化参数合法性
|
||||
CheckInitializeParameters(parameters);
|
||||
|
||||
// 销毁资源管理器
|
||||
if (_resourceManager != null)
|
||||
{
|
||||
_resourceManager.Destroy();
|
||||
_resourceManager = null;
|
||||
}
|
||||
|
||||
// 创建资源管理器
|
||||
InitializationOperation initializeOperation;
|
||||
_resourceManager = new ResourceManager(PackageName);
|
||||
@@ -257,6 +270,7 @@ namespace YooAsset
|
||||
return _playModeImpl.ClearCacheBundleFilesAsync(clearMode, clearParam);
|
||||
}
|
||||
|
||||
#region 包裹信息
|
||||
/// <summary>
|
||||
/// 获取当前激活包裹的版本信息
|
||||
/// </summary>
|
||||
@@ -283,6 +297,7 @@ namespace YooAsset
|
||||
DebugCheckInitialize();
|
||||
return _playModeImpl.ActiveManifest.GetPackageDetails();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 资源回收
|
||||
/// <summary>
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Security.Policy;
|
||||
using UnityEngine;
|
||||
using YooAsset;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using YooAsset;
|
||||
|
||||
/// <summary>
|
||||
/// 获取沙盒目录里缓存文件大小
|
||||
/// </summary>
|
||||
public class GetCacheBundleSizeOperation : GameAsyncOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
GetCacheFiles,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly string _packageName;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
/// <summary>
|
||||
/// 总大小(单位:字节)
|
||||
/// </summary>
|
||||
public long TotalSize = 0;
|
||||
|
||||
|
||||
public GetCacheBundleSizeOperation(string packageName)
|
||||
{
|
||||
_packageName = packageName;
|
||||
}
|
||||
protected override void OnStart()
|
||||
{
|
||||
_steps = ESteps.GetCacheFiles;
|
||||
}
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.GetCacheFiles)
|
||||
{
|
||||
long totalSize = 0;
|
||||
string directoryRoot = GetCacheDirectoryRoot();
|
||||
var directoryInfo = new DirectoryInfo(directoryRoot);
|
||||
if (directoryInfo.Exists)
|
||||
{
|
||||
FileInfo[] fileInfos = directoryInfo.GetFiles("*", SearchOption.AllDirectories);
|
||||
foreach (FileInfo fileInfo in fileInfos)
|
||||
{
|
||||
totalSize += fileInfo.Length;
|
||||
}
|
||||
}
|
||||
|
||||
TotalSize = totalSize;
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
}
|
||||
protected override void OnAbort()
|
||||
{
|
||||
}
|
||||
|
||||
private string GetCacheDirectoryRoot()
|
||||
{
|
||||
string rootDirectory = YooAssetSettingsData.GetYooMobileCacheRoot();
|
||||
string packageRoot = PathUtility.Combine(rootDirectory, _packageName);
|
||||
return PathUtility.Combine(packageRoot, DefaultCacheFileSystemDefine.SaveFilesFolderName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8790bf5eb17db6843b696018a2b1ce6a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -79,7 +79,7 @@ internal class FsmInitializePackage : IStateNode
|
||||
string defaultHostServer = GetHostServerURL();
|
||||
string fallbackHostServer = GetHostServerURL();
|
||||
IRemoteServices remoteServices = new RemoteServices(defaultHostServer, fallbackHostServer);
|
||||
createParameters.WebFileSystemParameters = WechatFileSystemCreater.CreateWechatFileSystemParameters(remoteServices);
|
||||
createParameters.WebServerFileSystemParameters = WechatFileSystemCreater.CreateWechatFileSystemParameters(remoteServices);
|
||||
#else
|
||||
createParameters.WebServerFileSystemParameters = FileSystemParameters.CreateDefaultWebServerFileSystemParameters();
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "com.tuyoogame.yooasset",
|
||||
"displayName": "YooAsset",
|
||||
"version": "2.2.5-preview",
|
||||
"version": "2.2.6-preview",
|
||||
"unity": "2019.4",
|
||||
"description": "unity3d resources management system.",
|
||||
"author": {
|
||||
|
||||
Reference in New Issue
Block a user