mirror of https://github.com/tuyoogame/YooAsset
parent
24c5108ce1
commit
589eea7cf3
|
@ -73,12 +73,7 @@ namespace YooAsset.Editor
|
||||||
if (buildResult.Success)
|
if (buildResult.Success)
|
||||||
{
|
{
|
||||||
SimulateBuildResult reulst = new SimulateBuildResult();
|
SimulateBuildResult reulst = new SimulateBuildResult();
|
||||||
string versionFileName = YooAssetSettingsData.GetPackageVersionFileName(packageName);
|
reulst.PackageRootDirectory = buildResult.OutputPackageDirectory;
|
||||||
string manifestFileName = YooAssetSettingsData.GetManifestBinaryFileName(packageName, packageVersion);
|
|
||||||
string hashFileName = YooAssetSettingsData.GetPackageHashFileName(packageName, packageVersion);
|
|
||||||
reulst.PackageVersionFilePath = $"{buildResult.OutputPackageDirectory}/{versionFileName}";
|
|
||||||
reulst.PackageManifestFilePath = $"{buildResult.OutputPackageDirectory}/{manifestFileName}";
|
|
||||||
reulst.PackageHashFilePath = $"{buildResult.OutputPackageDirectory}/{hashFileName}";
|
|
||||||
return reulst;
|
return reulst;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -106,19 +106,13 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
public virtual FSInitializeFileSystemOperation InitializeFileSystemAsync()
|
public virtual FSInitializeFileSystemOperation InitializeFileSystemAsync()
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
|
||||||
var operation = new DBFSInitializeInEditorPlayModeOperation(this);
|
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
|
||||||
return operation;
|
|
||||||
#else
|
|
||||||
var operation = new DBFSInitializeOperation(this);
|
var operation = new DBFSInitializeOperation(this);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(string packageVersion, int timeout)
|
public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(string packageVersion, int timeout)
|
||||||
{
|
{
|
||||||
var operation = new DBFSLoadPackageManifestOperation(this);
|
var operation = new DBFSLoadPackageManifestOperation(this, packageVersion);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
@ -311,6 +305,11 @@ namespace YooAsset
|
||||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(PackageName, packageVersion);
|
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(PackageName, packageVersion);
|
||||||
return PathUtility.Combine(FileRoot, fileName);
|
return PathUtility.Combine(FileRoot, fileName);
|
||||||
}
|
}
|
||||||
|
public string GetStreamingAssetsPackageRoot()
|
||||||
|
{
|
||||||
|
string rootPath = PathUtility.Combine(Application.dataPath, "StreamingAssets", YooAssetSettingsData.Setting.DefaultYooFolderName);
|
||||||
|
return PathUtility.Combine(rootPath, PackageName);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 记录文件信息
|
/// 记录文件信息
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace YooAsset
|
||||||
DirectoryInfo rootDirectory = new DirectoryInfo(rootPath);
|
DirectoryInfo rootDirectory = new DirectoryInfo(rootPath);
|
||||||
if (rootDirectory.Exists == false)
|
if (rootDirectory.Exists == false)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"Can not found buildin root folder : {rootPath}");
|
Debug.LogWarning($"Can not found StreamingAssets root directory : {rootPath}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,10 +32,14 @@ namespace YooAsset
|
||||||
DirectoryInfo[] subDirectories = rootDirectory.GetDirectories();
|
DirectoryInfo[] subDirectories = rootDirectory.GetDirectories();
|
||||||
foreach (var subDirectory in subDirectories)
|
foreach (var subDirectory in subDirectories)
|
||||||
{
|
{
|
||||||
CreateBuildinManifest(subDirectory.Name, subDirectory.FullName);
|
CreateBuildinCatalogFile(subDirectory.Name, subDirectory.FullName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void CreateBuildinManifest(string packageName, string pacakgeDirectory)
|
|
||||||
|
/// <summary>
|
||||||
|
/// 生成包裹的内置资源目录文件
|
||||||
|
/// </summary>
|
||||||
|
public static void CreateBuildinCatalogFile(string packageName, string pacakgeDirectory)
|
||||||
{
|
{
|
||||||
// 获取资源清单版本
|
// 获取资源清单版本
|
||||||
string packageVersion;
|
string packageVersion;
|
||||||
|
|
|
@ -56,6 +56,13 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
if (_loadCatalogFileOp == null)
|
if (_loadCatalogFileOp == null)
|
||||||
{
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
// 兼容性初始化
|
||||||
|
// 说明:内置文件系统在编辑器下运行时需要动态生成
|
||||||
|
string packageRoot = _fileSystem.GetStreamingAssetsPackageRoot();
|
||||||
|
DefaultBuildinFileSystemBuild.CreateBuildinCatalogFile(_fileSystem.PackageName, packageRoot);
|
||||||
|
#endif
|
||||||
|
|
||||||
_loadCatalogFileOp = new LoadBuildinCatalogFileOperation(_fileSystem);
|
_loadCatalogFileOp = new LoadBuildinCatalogFileOperation(_fileSystem);
|
||||||
OperationSystem.StartOperation(_fileSystem.PackageName, _loadCatalogFileOp);
|
OperationSystem.StartOperation(_fileSystem.PackageName, _loadCatalogFileOp);
|
||||||
}
|
}
|
||||||
|
@ -77,110 +84,4 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 在编辑器下离线模式的兼容性初始化
|
|
||||||
/// </summary>
|
|
||||||
internal sealed class DBFSInitializeInEditorPlayModeOperation : FSInitializeFileSystemOperation
|
|
||||||
{
|
|
||||||
private enum ESteps
|
|
||||||
{
|
|
||||||
None,
|
|
||||||
InitUnpackFileSystem,
|
|
||||||
LoadPackageManifest,
|
|
||||||
RecordFiles,
|
|
||||||
Done,
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
|
||||||
private FSInitializeFileSystemOperation _initUnpackFIleSystemOp;
|
|
||||||
private DBFSLoadPackageManifestOperation _loadPackageManifestOp;
|
|
||||||
private ESteps _steps = ESteps.None;
|
|
||||||
|
|
||||||
internal DBFSInitializeInEditorPlayModeOperation(DefaultBuildinFileSystem fileSystem)
|
|
||||||
{
|
|
||||||
_fileSystem = fileSystem;
|
|
||||||
}
|
|
||||||
internal override void InternalOnStart()
|
|
||||||
{
|
|
||||||
_steps = ESteps.InitUnpackFileSystem;
|
|
||||||
}
|
|
||||||
internal override void InternalOnUpdate()
|
|
||||||
{
|
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (_steps == ESteps.InitUnpackFileSystem)
|
|
||||||
{
|
|
||||||
if (_initUnpackFIleSystemOp == null)
|
|
||||||
_initUnpackFIleSystemOp = _fileSystem.InitializeUpackFileSystem();
|
|
||||||
|
|
||||||
Progress = _initUnpackFIleSystemOp.Progress;
|
|
||||||
if (_initUnpackFIleSystemOp.IsDone == false)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (_initUnpackFIleSystemOp.Status == EOperationStatus.Succeed)
|
|
||||||
{
|
|
||||||
_steps = ESteps.LoadPackageManifest;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = _initUnpackFIleSystemOp.Error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_steps == ESteps.LoadPackageManifest)
|
|
||||||
{
|
|
||||||
if (_loadPackageManifestOp == null)
|
|
||||||
{
|
|
||||||
_loadPackageManifestOp = new DBFSLoadPackageManifestOperation(_fileSystem);
|
|
||||||
OperationSystem.StartOperation(_fileSystem.PackageName, _loadPackageManifestOp);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_loadPackageManifestOp.IsDone == false)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (_loadPackageManifestOp.Status == EOperationStatus.Succeed)
|
|
||||||
{
|
|
||||||
_steps = ESteps.RecordFiles;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = _loadPackageManifestOp.Error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_steps == ESteps.RecordFiles)
|
|
||||||
{
|
|
||||||
PackageManifest manifest = _loadPackageManifestOp.Manifest;
|
|
||||||
string pacakgeDirectory = _fileSystem.FileRoot;
|
|
||||||
DirectoryInfo rootDirectory = new DirectoryInfo(pacakgeDirectory);
|
|
||||||
FileInfo[] fileInfos = rootDirectory.GetFiles();
|
|
||||||
foreach (var fileInfo in fileInfos)
|
|
||||||
{
|
|
||||||
if (fileInfo.Extension == ".meta" || fileInfo.Extension == ".version" ||
|
|
||||||
fileInfo.Extension == ".hash" || fileInfo.Extension == ".bytes")
|
|
||||||
continue;
|
|
||||||
|
|
||||||
string fileName = fileInfo.Name;
|
|
||||||
if (manifest.TryGetPackageBundleByFileName(fileName, out PackageBundle value))
|
|
||||||
{
|
|
||||||
var fileWrapper = new DefaultBuildinFileSystem.FileWrapper(fileName);
|
|
||||||
_fileSystem.RecordFile(value.BundleGUID, fileWrapper);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
YooLogger.Warning($"Failed to mapping buildin bundle file : {fileName}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Succeed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -6,61 +6,37 @@ namespace YooAsset
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
RequestBuildinPackageVersion,
|
|
||||||
RequestBuildinPackageHash,
|
RequestBuildinPackageHash,
|
||||||
LoadBuildinPackageManifest,
|
LoadBuildinPackageManifest,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||||
private RequestBuildinPackageVersionOperation _requestBuildinPackageVersionOp;
|
private readonly string _packageVersion;
|
||||||
private RequestBuildinPackageHashOperation _requestBuildinPackageHashOp;
|
private RequestBuildinPackageHashOperation _requestBuildinPackageHashOp;
|
||||||
private LoadBuildinPackageManifestOperation _loadBuildinPackageManifestOp;
|
private LoadBuildinPackageManifestOperation _loadBuildinPackageManifestOp;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
|
||||||
public DBFSLoadPackageManifestOperation(DefaultBuildinFileSystem fileSystem)
|
public DBFSLoadPackageManifestOperation(DefaultBuildinFileSystem fileSystem, string packageVersion)
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
|
_packageVersion = packageVersion;
|
||||||
}
|
}
|
||||||
internal override void InternalOnStart()
|
internal override void InternalOnStart()
|
||||||
{
|
{
|
||||||
_steps = ESteps.RequestBuildinPackageVersion;
|
_steps = ESteps.RequestBuildinPackageHash;
|
||||||
}
|
}
|
||||||
internal override void InternalOnUpdate()
|
internal override void InternalOnUpdate()
|
||||||
{
|
{
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_steps == ESteps.RequestBuildinPackageVersion)
|
|
||||||
{
|
|
||||||
if (_requestBuildinPackageVersionOp == null)
|
|
||||||
{
|
|
||||||
_requestBuildinPackageVersionOp = new RequestBuildinPackageVersionOperation(_fileSystem);
|
|
||||||
OperationSystem.StartOperation(_fileSystem.PackageName, _requestBuildinPackageVersionOp);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_requestBuildinPackageVersionOp.IsDone == false)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (_requestBuildinPackageVersionOp.Status == EOperationStatus.Succeed)
|
|
||||||
{
|
|
||||||
_steps = ESteps.RequestBuildinPackageHash;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = _requestBuildinPackageVersionOp.Error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_steps == ESteps.RequestBuildinPackageHash)
|
if (_steps == ESteps.RequestBuildinPackageHash)
|
||||||
{
|
{
|
||||||
if (_requestBuildinPackageHashOp == null)
|
if (_requestBuildinPackageHashOp == null)
|
||||||
{
|
{
|
||||||
string packageVersion = _requestBuildinPackageVersionOp.PackageVersion;
|
_requestBuildinPackageHashOp = new RequestBuildinPackageHashOperation(_fileSystem, _packageVersion);
|
||||||
_requestBuildinPackageHashOp = new RequestBuildinPackageHashOperation(_fileSystem, packageVersion);
|
|
||||||
OperationSystem.StartOperation(_fileSystem.PackageName, _requestBuildinPackageHashOp);
|
OperationSystem.StartOperation(_fileSystem.PackageName, _requestBuildinPackageHashOp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,9 +59,8 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
if (_loadBuildinPackageManifestOp == null)
|
if (_loadBuildinPackageManifestOp == null)
|
||||||
{
|
{
|
||||||
string packageVersion = _requestBuildinPackageVersionOp.PackageVersion;
|
|
||||||
string packageHash = _requestBuildinPackageHashOp.PackageHash;
|
string packageHash = _requestBuildinPackageHashOp.PackageHash;
|
||||||
_loadBuildinPackageManifestOp = new LoadBuildinPackageManifestOperation(_fileSystem, packageVersion, packageHash);
|
_loadBuildinPackageManifestOp = new LoadBuildinPackageManifestOperation(_fileSystem, _packageVersion, packageHash);
|
||||||
OperationSystem.StartOperation(_fileSystem.PackageName, _loadBuildinPackageManifestOp);
|
OperationSystem.StartOperation(_fileSystem.PackageName, _loadBuildinPackageManifestOp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -35,13 +36,6 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 自定义参数
|
|
||||||
/// <summary>
|
|
||||||
/// 自定义参数:模拟构建结果
|
|
||||||
/// </summary>
|
|
||||||
public SimulateBuildResult BuildResult { private set; get; } = null;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
|
||||||
public DefaultEditorFileSystem()
|
public DefaultEditorFileSystem()
|
||||||
{
|
{
|
||||||
|
@ -54,7 +48,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(string packageVersion, int timeout)
|
public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(string packageVersion, int timeout)
|
||||||
{
|
{
|
||||||
var operation = new DEFSLoadPackageManifestOperation(this);
|
var operation = new DEFSLoadPackageManifestOperation(this, packageVersion);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
@ -92,23 +86,17 @@ namespace YooAsset
|
||||||
|
|
||||||
public virtual void SetParameter(string name, object value)
|
public virtual void SetParameter(string name, object value)
|
||||||
{
|
{
|
||||||
if (name == "SIMULATE_BUILD_RESULT")
|
YooLogger.Warning($"Invalid parameter : {name}");
|
||||||
{
|
|
||||||
BuildResult = (SimulateBuildResult)value;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
YooLogger.Warning($"Invalid parameter : {name}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public virtual void OnCreate(string packageName, string rootDirectory)
|
public virtual void OnCreate(string packageName, string rootDirectory)
|
||||||
{
|
{
|
||||||
PackageName = packageName;
|
PackageName = packageName;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(rootDirectory))
|
if (string.IsNullOrEmpty(rootDirectory))
|
||||||
rootDirectory = GetDefaultRoot();
|
throw new Exception($"{nameof(DefaultEditorFileSystem)} root directory is null or empty !");
|
||||||
|
|
||||||
_packageRoot = PathUtility.Combine(rootDirectory, packageName);
|
// 注意:基础目录即为包裹目录
|
||||||
|
_packageRoot = rootDirectory;
|
||||||
}
|
}
|
||||||
public virtual void OnUpdate()
|
public virtual void OnUpdate()
|
||||||
{
|
{
|
||||||
|
@ -145,9 +133,20 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 内部方法
|
#region 内部方法
|
||||||
protected string GetDefaultRoot()
|
public string GetEditorPackageVersionFilePath()
|
||||||
{
|
{
|
||||||
return "Assets/";
|
string fileName = YooAssetSettingsData.GetPackageVersionFileName(PackageName);
|
||||||
|
return PathUtility.Combine(FileRoot, fileName);
|
||||||
|
}
|
||||||
|
public string GetEditorPackageHashFilePath(string packageVersion)
|
||||||
|
{
|
||||||
|
string fileName = YooAssetSettingsData.GetPackageHashFileName(PackageName, packageVersion);
|
||||||
|
return PathUtility.Combine(FileRoot, fileName);
|
||||||
|
}
|
||||||
|
public string GetEditorPackageManifestFilePath(string packageVersion)
|
||||||
|
{
|
||||||
|
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(PackageName, packageVersion);
|
||||||
|
return PathUtility.Combine(FileRoot, fileName);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,33 +6,61 @@ namespace YooAsset
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
LoadEditorPackageHash,
|
||||||
LoadEditorPackageManifest,
|
LoadEditorPackageManifest,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly DefaultEditorFileSystem _fileSystem;
|
private readonly DefaultEditorFileSystem _fileSystem;
|
||||||
|
private readonly string _packageVersion;
|
||||||
|
private LoadEditorPackageHashOperation _loadEditorPackageHashOpe;
|
||||||
private LoadEditorPackageManifestOperation _loadEditorPackageManifestOp;
|
private LoadEditorPackageManifestOperation _loadEditorPackageManifestOp;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
|
||||||
internal DEFSLoadPackageManifestOperation(DefaultEditorFileSystem fileSystem)
|
internal DEFSLoadPackageManifestOperation(DefaultEditorFileSystem fileSystem, string packageVersion)
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
|
_packageVersion = packageVersion;
|
||||||
}
|
}
|
||||||
internal override void InternalOnStart()
|
internal override void InternalOnStart()
|
||||||
{
|
{
|
||||||
_steps = ESteps.LoadEditorPackageManifest;
|
_steps = ESteps.LoadEditorPackageHash;
|
||||||
}
|
}
|
||||||
internal override void InternalOnUpdate()
|
internal override void InternalOnUpdate()
|
||||||
{
|
{
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.LoadEditorPackageHash)
|
||||||
|
{
|
||||||
|
if (_loadEditorPackageHashOpe == null)
|
||||||
|
{
|
||||||
|
_loadEditorPackageHashOpe = new LoadEditorPackageHashOperation(_fileSystem, _packageVersion);
|
||||||
|
OperationSystem.StartOperation(_fileSystem.PackageName, _loadEditorPackageHashOpe);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_loadEditorPackageHashOpe.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_loadEditorPackageHashOpe.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
_steps = ESteps.LoadEditorPackageManifest;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _loadEditorPackageHashOpe.Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.LoadEditorPackageManifest)
|
if (_steps == ESteps.LoadEditorPackageManifest)
|
||||||
{
|
{
|
||||||
if (_loadEditorPackageManifestOp == null)
|
if (_loadEditorPackageManifestOp == null)
|
||||||
{
|
{
|
||||||
_loadEditorPackageManifestOp = new LoadEditorPackageManifestOperation(_fileSystem);
|
string packageHash = _loadEditorPackageHashOpe.PackageHash;
|
||||||
|
_loadEditorPackageManifestOp = new LoadEditorPackageManifestOperation(_fileSystem, _packageVersion, packageHash);
|
||||||
OperationSystem.StartOperation(_fileSystem.PackageName, _loadEditorPackageManifestOp);
|
OperationSystem.StartOperation(_fileSystem.PackageName, _loadEditorPackageManifestOp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
internal class LoadEditorPackageHashOperation : AsyncOperationBase
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
LoadHash,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly DefaultEditorFileSystem _fileSystem;
|
||||||
|
private readonly string _packageVersion;
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 包裹哈希值
|
||||||
|
/// </summary>
|
||||||
|
public string PackageHash { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
|
internal LoadEditorPackageHashOperation(DefaultEditorFileSystem fileSystem, string packageVersion)
|
||||||
|
{
|
||||||
|
_fileSystem = fileSystem;
|
||||||
|
_packageVersion = packageVersion;
|
||||||
|
}
|
||||||
|
internal override void InternalOnStart()
|
||||||
|
{
|
||||||
|
_steps = ESteps.LoadHash;
|
||||||
|
}
|
||||||
|
internal override void InternalOnUpdate()
|
||||||
|
{
|
||||||
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.LoadHash)
|
||||||
|
{
|
||||||
|
string hashFilePath = _fileSystem.GetEditorPackageHashFilePath(_packageVersion);
|
||||||
|
if (File.Exists(hashFilePath))
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
PackageHash = FileUtility.ReadAllText(hashFilePath);
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"Can not found simulation package hash file : {hashFilePath}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 137c898b6a637c74d8d5e281e6124a72
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -8,11 +8,14 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
LoadFileData,
|
LoadFileData,
|
||||||
|
VerifyFileData,
|
||||||
LoadManifest,
|
LoadManifest,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly DefaultEditorFileSystem _fileSystem;
|
private readonly DefaultEditorFileSystem _fileSystem;
|
||||||
|
private readonly string _packageVersion;
|
||||||
|
private readonly string _packageHash;
|
||||||
private DeserializeManifestOperation _deserializer;
|
private DeserializeManifestOperation _deserializer;
|
||||||
private byte[] _fileData;
|
private byte[] _fileData;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
@ -23,9 +26,11 @@ namespace YooAsset
|
||||||
public PackageManifest Manifest { private set; get; }
|
public PackageManifest Manifest { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
internal LoadEditorPackageManifestOperation(DefaultEditorFileSystem fileSystem)
|
internal LoadEditorPackageManifestOperation(DefaultEditorFileSystem fileSystem, string packageVersion, string packageHash)
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
|
_packageVersion = packageVersion;
|
||||||
|
_packageHash = packageHash;
|
||||||
}
|
}
|
||||||
internal override void InternalOnStart()
|
internal override void InternalOnStart()
|
||||||
{
|
{
|
||||||
|
@ -38,10 +43,10 @@ namespace YooAsset
|
||||||
|
|
||||||
if (_steps == ESteps.LoadFileData)
|
if (_steps == ESteps.LoadFileData)
|
||||||
{
|
{
|
||||||
string manifestFilePath = _fileSystem.BuildResult.PackageManifestFilePath;
|
string manifestFilePath = _fileSystem.GetEditorPackageManifestFilePath(_packageVersion);
|
||||||
if (File.Exists(manifestFilePath))
|
if (File.Exists(manifestFilePath))
|
||||||
{
|
{
|
||||||
_steps = ESteps.LoadManifest;
|
_steps = ESteps.VerifyFileData;
|
||||||
_fileData = FileUtility.ReadAllBytes(manifestFilePath);
|
_fileData = FileUtility.ReadAllBytes(manifestFilePath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -52,6 +57,21 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.VerifyFileData)
|
||||||
|
{
|
||||||
|
string fileHash = HashUtility.BytesMD5(_fileData);
|
||||||
|
if (fileHash == _packageHash)
|
||||||
|
{
|
||||||
|
_steps = ESteps.LoadManifest;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = "Failed to verify simulation package manifest file !";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.LoadManifest)
|
if (_steps == ESteps.LoadManifest)
|
||||||
{
|
{
|
||||||
if (_deserializer == null)
|
if (_deserializer == null)
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace YooAsset
|
||||||
|
|
||||||
if (_steps == ESteps.LoadVersion)
|
if (_steps == ESteps.LoadVersion)
|
||||||
{
|
{
|
||||||
string versionFilePath = _fileSystem.BuildResult.PackageVersionFilePath;
|
string versionFilePath = _fileSystem.GetEditorPackageVersionFilePath();
|
||||||
if (File.Exists(versionFilePath))
|
if (File.Exists(versionFilePath))
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
|
|
|
@ -201,6 +201,11 @@ namespace YooAsset
|
||||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(PackageName, packageVersion);
|
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(PackageName, packageVersion);
|
||||||
return PathUtility.Combine(FileRoot, fileName);
|
return PathUtility.Combine(FileRoot, fileName);
|
||||||
}
|
}
|
||||||
|
public string GetStreamingAssetsPackageRoot()
|
||||||
|
{
|
||||||
|
string rootPath = PathUtility.Combine(Application.dataPath, "StreamingAssets", YooAssetSettingsData.Setting.DefaultYooFolderName);
|
||||||
|
return PathUtility.Combine(rootPath, PackageName);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 记录文件信息
|
/// 记录文件信息
|
||||||
|
|
|
@ -32,6 +32,13 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
if (_loadCatalogFileOp == null)
|
if (_loadCatalogFileOp == null)
|
||||||
{
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
// 兼容性初始化
|
||||||
|
// 说明:内置文件系统在编辑器下运行时需要动态生成
|
||||||
|
string packageRoot = _fileSystem.GetStreamingAssetsPackageRoot();
|
||||||
|
DefaultBuildinFileSystemBuild.CreateBuildinCatalogFile(_fileSystem.PackageName, packageRoot);
|
||||||
|
#endif
|
||||||
|
|
||||||
_loadCatalogFileOp = new LoadWebCatalogFileOperation(_fileSystem);
|
_loadCatalogFileOp = new LoadWebCatalogFileOperation(_fileSystem);
|
||||||
OperationSystem.StartOperation(_fileSystem.PackageName, _loadCatalogFileOp);
|
OperationSystem.StartOperation(_fileSystem.PackageName, _loadCatalogFileOp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,8 +92,7 @@ namespace YooAsset
|
||||||
public static FileSystemParameters CreateDefaultEditorFileSystemParameters(SimulateBuildResult simulateBuildResult)
|
public static FileSystemParameters CreateDefaultEditorFileSystemParameters(SimulateBuildResult simulateBuildResult)
|
||||||
{
|
{
|
||||||
string fileSystemClass = typeof(DefaultEditorFileSystem).FullName;
|
string fileSystemClass = typeof(DefaultEditorFileSystem).FullName;
|
||||||
var fileSystemParams = new FileSystemParameters(fileSystemClass, null);
|
var fileSystemParams = new FileSystemParameters(fileSystemClass, simulateBuildResult.PackageRootDirectory);
|
||||||
fileSystemParams.AddParameter("SIMULATE_BUILD_RESULT", simulateBuildResult);
|
|
||||||
return fileSystemParams;
|
return fileSystemParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,14 +18,12 @@ namespace YooAsset
|
||||||
None,
|
None,
|
||||||
CreateFileSystem,
|
CreateFileSystem,
|
||||||
InitFileSystem,
|
InitFileSystem,
|
||||||
LoadManifestFile,
|
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly EditorSimulateModeImpl _impl;
|
private readonly EditorSimulateModeImpl _impl;
|
||||||
private readonly EditorSimulateModeParameters _parameters;
|
private readonly EditorSimulateModeParameters _parameters;
|
||||||
private FSInitializeFileSystemOperation _initFileSystemOp;
|
private FSInitializeFileSystemOperation _initFileSystemOp;
|
||||||
private FSLoadPackageManifestOperation _loadPackageManifestOp;
|
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
internal EditorSimulateModeInitializationOperation(EditorSimulateModeImpl impl, EditorSimulateModeParameters parameters)
|
internal EditorSimulateModeInitializationOperation(EditorSimulateModeImpl impl, EditorSimulateModeParameters parameters)
|
||||||
|
@ -71,37 +69,15 @@ namespace YooAsset
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_initFileSystemOp.Status == EOperationStatus.Succeed)
|
if (_initFileSystemOp.Status == EOperationStatus.Succeed)
|
||||||
{
|
|
||||||
_steps = ESteps.LoadManifestFile;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = _initFileSystemOp.Error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_steps == ESteps.LoadManifestFile)
|
|
||||||
{
|
|
||||||
if (_loadPackageManifestOp == null)
|
|
||||||
_loadPackageManifestOp = _impl.EditorFileSystem.LoadPackageManifestAsync(null, int.MaxValue);
|
|
||||||
|
|
||||||
Progress = _loadPackageManifestOp.Progress;
|
|
||||||
if (_loadPackageManifestOp.IsDone == false)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (_loadPackageManifestOp.Status == EOperationStatus.Succeed)
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
_impl.ActiveManifest = _loadPackageManifestOp.Manifest;
|
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = _loadPackageManifestOp.Error;
|
Error = _initFileSystemOp.Error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,13 +93,13 @@ namespace YooAsset
|
||||||
None,
|
None,
|
||||||
CreateFileSystem,
|
CreateFileSystem,
|
||||||
InitFileSystem,
|
InitFileSystem,
|
||||||
LoadManifestFile,
|
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly OfflinePlayModeImpl _impl;
|
private readonly OfflinePlayModeImpl _impl;
|
||||||
private readonly OfflinePlayModeParameters _parameters;
|
private readonly OfflinePlayModeParameters _parameters;
|
||||||
private FSInitializeFileSystemOperation _initFileSystemOp;
|
private FSInitializeFileSystemOperation _initFileSystemOp;
|
||||||
|
private FSRequestPackageVersionOperation _requestPackageVersionOp;
|
||||||
private FSLoadPackageManifestOperation _loadPackageManifestOp;
|
private FSLoadPackageManifestOperation _loadPackageManifestOp;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
@ -173,37 +149,15 @@ namespace YooAsset
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_initFileSystemOp.Status == EOperationStatus.Succeed)
|
if (_initFileSystemOp.Status == EOperationStatus.Succeed)
|
||||||
{
|
|
||||||
_steps = ESteps.LoadManifestFile;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = _initFileSystemOp.Error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_steps == ESteps.LoadManifestFile)
|
|
||||||
{
|
|
||||||
if (_loadPackageManifestOp == null)
|
|
||||||
_loadPackageManifestOp = _impl.BuildinFileSystem.LoadPackageManifestAsync(null, int.MaxValue);
|
|
||||||
|
|
||||||
Progress = _loadPackageManifestOp.Progress;
|
|
||||||
if (_loadPackageManifestOp.IsDone == false)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (_loadPackageManifestOp.Status == EOperationStatus.Succeed)
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
_impl.ActiveManifest = _loadPackageManifestOp.Manifest;
|
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = _loadPackageManifestOp.Error;
|
Error = _initFileSystemOp.Error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,6 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
public class SimulateBuildResult
|
public class SimulateBuildResult
|
||||||
{
|
{
|
||||||
public string PackageVersionFilePath;
|
public string PackageRootDirectory;
|
||||||
public string PackageManifestFilePath;
|
|
||||||
public string PackageHashFilePath;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue