Files
YooAssetScene/Assets/YooAsset/Runtime/ResourcePackage/BundleInfo.cs
T
何冠峰 ff02da5c54 refactor the runtime code
重构了运行时代码,支持全新的文件系统。
2024-07-04 20:36:26 +08:00

76 lines
2.0 KiB
C#

using System.IO;
using System.Collections.Generic;
using UnityEngine;
namespace YooAsset
{
internal class BundleInfo
{
private readonly string _importFilePath;
private readonly IFileSystem _fileSystem;
/// <summary>
/// 资源包对象
/// </summary>
public readonly PackageBundle Bundle;
/// <summary>
/// 注意:该字段只用于帮助编辑器下的模拟模式。
/// </summary>
public string[] IncludeAssetsInEditor;
public BundleInfo(IFileSystem fileSystem, PackageBundle bundle)
{
_fileSystem = fileSystem;
Bundle = bundle;
_importFilePath = null;
}
public BundleInfo(IFileSystem fileSystem, PackageBundle bundle, string importFilePath)
{
_fileSystem = fileSystem;
Bundle = bundle;
_importFilePath = importFilePath;
}
/// <summary>
/// 加载资源文件
/// </summary>
public FSLoadBundleOperation LoadBundleFile()
{
return _fileSystem.LoadBundleFile(Bundle);
}
/// <summary>
/// 卸载资源文件
/// </summary>
public void UnloadBundleFile(object result)
{
_fileSystem.UnloadBundleFile(Bundle, result);
}
/// <summary>
/// 创建下载器
/// </summary>
public FSDownloadFileOperation CreateDownloader(int failedTryAgain, int timeout)
{
return _fileSystem.DownloadFileAsync(Bundle, _importFilePath, failedTryAgain, timeout);
}
/// <summary>
/// 是否需要从远端下载
/// </summary>
public bool IsNeedDownloadFromRemote()
{
return _fileSystem.CheckNeedDownload(Bundle);
}
/// <summary>
/// 下载器合并识别码
/// </summary>
public string GetDownloadCombineGUID()
{
return $"{_fileSystem.GetHashCode()}_{Bundle.BundleGUID}";
}
}
}