mirror of https://github.com/tuyoogame/YooAsset
parent
24c5108ce1
commit
589eea7cf3
|
@ -73,12 +73,7 @@ namespace YooAsset.Editor
|
|||
if (buildResult.Success)
|
||||
{
|
||||
SimulateBuildResult reulst = new SimulateBuildResult();
|
||||
string versionFileName = YooAssetSettingsData.GetPackageVersionFileName(packageName);
|
||||
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}";
|
||||
reulst.PackageRootDirectory = buildResult.OutputPackageDirectory;
|
||||
return reulst;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -106,19 +106,13 @@ namespace YooAsset
|
|||
}
|
||||
public virtual FSInitializeFileSystemOperation InitializeFileSystemAsync()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
var operation = new DBFSInitializeInEditorPlayModeOperation(this);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
#else
|
||||
var operation = new DBFSInitializeOperation(this);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
#endif
|
||||
}
|
||||
public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(string packageVersion, int timeout)
|
||||
{
|
||||
var operation = new DBFSLoadPackageManifestOperation(this);
|
||||
var operation = new DBFSLoadPackageManifestOperation(this, packageVersion);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
@ -311,7 +305,12 @@ namespace YooAsset
|
|||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(PackageName, packageVersion);
|
||||
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);
|
||||
if (rootDirectory.Exists == false)
|
||||
{
|
||||
Debug.LogWarning($"Can not found buildin root folder : {rootPath}");
|
||||
Debug.LogWarning($"Can not found StreamingAssets root directory : {rootPath}");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -32,10 +32,14 @@ namespace YooAsset
|
|||
DirectoryInfo[] subDirectories = rootDirectory.GetDirectories();
|
||||
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;
|
||||
|
|
|
@ -56,6 +56,13 @@ namespace YooAsset
|
|||
{
|
||||
if (_loadCatalogFileOp == null)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
// 兼容性初始化
|
||||
// 说明:内置文件系统在编辑器下运行时需要动态生成
|
||||
string packageRoot = _fileSystem.GetStreamingAssetsPackageRoot();
|
||||
DefaultBuildinFileSystemBuild.CreateBuildinCatalogFile(_fileSystem.PackageName, packageRoot);
|
||||
#endif
|
||||
|
||||
_loadCatalogFileOp = new LoadBuildinCatalogFileOperation(_fileSystem);
|
||||
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
|
||||
{
|
||||
None,
|
||||
RequestBuildinPackageVersion,
|
||||
RequestBuildinPackageHash,
|
||||
LoadBuildinPackageManifest,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||
private RequestBuildinPackageVersionOperation _requestBuildinPackageVersionOp;
|
||||
private readonly string _packageVersion;
|
||||
private RequestBuildinPackageHashOperation _requestBuildinPackageHashOp;
|
||||
private LoadBuildinPackageManifestOperation _loadBuildinPackageManifestOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
public DBFSLoadPackageManifestOperation(DefaultBuildinFileSystem fileSystem)
|
||||
public DBFSLoadPackageManifestOperation(DefaultBuildinFileSystem fileSystem, string packageVersion)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_packageVersion = packageVersion;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.RequestBuildinPackageVersion;
|
||||
_steps = ESteps.RequestBuildinPackageHash;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
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 (_requestBuildinPackageHashOp == null)
|
||||
{
|
||||
string packageVersion = _requestBuildinPackageVersionOp.PackageVersion;
|
||||
_requestBuildinPackageHashOp = new RequestBuildinPackageHashOperation(_fileSystem, packageVersion);
|
||||
_requestBuildinPackageHashOp = new RequestBuildinPackageHashOperation(_fileSystem, _packageVersion);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _requestBuildinPackageHashOp);
|
||||
}
|
||||
|
||||
|
@ -83,9 +59,8 @@ namespace YooAsset
|
|||
{
|
||||
if (_loadBuildinPackageManifestOp == null)
|
||||
{
|
||||
string packageVersion = _requestBuildinPackageVersionOp.PackageVersion;
|
||||
string packageHash = _requestBuildinPackageHashOp.PackageHash;
|
||||
_loadBuildinPackageManifestOp = new LoadBuildinPackageManifestOperation(_fileSystem, packageVersion, packageHash);
|
||||
_loadBuildinPackageManifestOp = new LoadBuildinPackageManifestOperation(_fileSystem, _packageVersion, packageHash);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _loadBuildinPackageManifestOp);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
|
||||
using System;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -35,13 +36,6 @@ namespace YooAsset
|
|||
}
|
||||
}
|
||||
|
||||
#region 自定义参数
|
||||
/// <summary>
|
||||
/// 自定义参数:模拟构建结果
|
||||
/// </summary>
|
||||
public SimulateBuildResult BuildResult { private set; get; } = null;
|
||||
#endregion
|
||||
|
||||
|
||||
public DefaultEditorFileSystem()
|
||||
{
|
||||
|
@ -54,7 +48,7 @@ namespace YooAsset
|
|||
}
|
||||
public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(string packageVersion, int timeout)
|
||||
{
|
||||
var operation = new DEFSLoadPackageManifestOperation(this);
|
||||
var operation = new DEFSLoadPackageManifestOperation(this, packageVersion);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
@ -92,23 +86,17 @@ namespace YooAsset
|
|||
|
||||
public virtual void SetParameter(string name, object value)
|
||||
{
|
||||
if (name == "SIMULATE_BUILD_RESULT")
|
||||
{
|
||||
BuildResult = (SimulateBuildResult)value;
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Warning($"Invalid parameter : {name}");
|
||||
}
|
||||
YooLogger.Warning($"Invalid parameter : {name}");
|
||||
}
|
||||
public virtual void OnCreate(string packageName, string rootDirectory)
|
||||
{
|
||||
PackageName = packageName;
|
||||
|
||||
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()
|
||||
{
|
||||
|
@ -143,11 +131,22 @@ namespace YooAsset
|
|||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
#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
|
||||
}
|
||||
|
|
|
@ -6,33 +6,61 @@ namespace YooAsset
|
|||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
LoadEditorPackageHash,
|
||||
LoadEditorPackageManifest,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultEditorFileSystem _fileSystem;
|
||||
private readonly string _packageVersion;
|
||||
private LoadEditorPackageHashOperation _loadEditorPackageHashOpe;
|
||||
private LoadEditorPackageManifestOperation _loadEditorPackageManifestOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal DEFSLoadPackageManifestOperation(DefaultEditorFileSystem fileSystem)
|
||||
internal DEFSLoadPackageManifestOperation(DefaultEditorFileSystem fileSystem, string packageVersion)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_packageVersion = packageVersion;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.LoadEditorPackageManifest;
|
||||
_steps = ESteps.LoadEditorPackageHash;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
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 (_loadEditorPackageManifestOp == null)
|
||||
{
|
||||
_loadEditorPackageManifestOp = new LoadEditorPackageManifestOperation(_fileSystem);
|
||||
string packageHash = _loadEditorPackageHashOpe.PackageHash;
|
||||
_loadEditorPackageManifestOp = new LoadEditorPackageManifestOperation(_fileSystem, _packageVersion, packageHash);
|
||||
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,
|
||||
LoadFileData,
|
||||
VerifyFileData,
|
||||
LoadManifest,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultEditorFileSystem _fileSystem;
|
||||
private readonly string _packageVersion;
|
||||
private readonly string _packageHash;
|
||||
private DeserializeManifestOperation _deserializer;
|
||||
private byte[] _fileData;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
@ -23,9 +26,11 @@ namespace YooAsset
|
|||
public PackageManifest Manifest { private set; get; }
|
||||
|
||||
|
||||
internal LoadEditorPackageManifestOperation(DefaultEditorFileSystem fileSystem)
|
||||
internal LoadEditorPackageManifestOperation(DefaultEditorFileSystem fileSystem, string packageVersion, string packageHash)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_packageVersion = packageVersion;
|
||||
_packageHash = packageHash;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
|
@ -38,10 +43,10 @@ namespace YooAsset
|
|||
|
||||
if (_steps == ESteps.LoadFileData)
|
||||
{
|
||||
string manifestFilePath = _fileSystem.BuildResult.PackageManifestFilePath;
|
||||
string manifestFilePath = _fileSystem.GetEditorPackageManifestFilePath(_packageVersion);
|
||||
if (File.Exists(manifestFilePath))
|
||||
{
|
||||
_steps = ESteps.LoadManifest;
|
||||
_steps = ESteps.VerifyFileData;
|
||||
_fileData = FileUtility.ReadAllBytes(manifestFilePath);
|
||||
}
|
||||
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 (_deserializer == null)
|
||||
|
@ -67,7 +87,7 @@ namespace YooAsset
|
|||
if (_deserializer.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Manifest = _deserializer.Manifest;
|
||||
Manifest = _deserializer.Manifest;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace YooAsset
|
|||
|
||||
if (_steps == ESteps.LoadVersion)
|
||||
{
|
||||
string versionFilePath = _fileSystem.BuildResult.PackageVersionFilePath;
|
||||
string versionFilePath = _fileSystem.GetEditorPackageVersionFilePath();
|
||||
if (File.Exists(versionFilePath))
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
|
|
|
@ -201,6 +201,11 @@ namespace YooAsset
|
|||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(PackageName, packageVersion);
|
||||
return PathUtility.Combine(FileRoot, fileName);
|
||||
}
|
||||
public string GetStreamingAssetsPackageRoot()
|
||||
{
|
||||
string rootPath = PathUtility.Combine(Application.dataPath, "StreamingAssets", YooAssetSettingsData.Setting.DefaultYooFolderName);
|
||||
return PathUtility.Combine(rootPath, PackageName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 记录文件信息
|
||||
|
|
|
@ -32,6 +32,13 @@ namespace YooAsset
|
|||
{
|
||||
if (_loadCatalogFileOp == null)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
// 兼容性初始化
|
||||
// 说明:内置文件系统在编辑器下运行时需要动态生成
|
||||
string packageRoot = _fileSystem.GetStreamingAssetsPackageRoot();
|
||||
DefaultBuildinFileSystemBuild.CreateBuildinCatalogFile(_fileSystem.PackageName, packageRoot);
|
||||
#endif
|
||||
|
||||
_loadCatalogFileOp = new LoadWebCatalogFileOperation(_fileSystem);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _loadCatalogFileOp);
|
||||
}
|
||||
|
|
|
@ -92,8 +92,7 @@ namespace YooAsset
|
|||
public static FileSystemParameters CreateDefaultEditorFileSystemParameters(SimulateBuildResult simulateBuildResult)
|
||||
{
|
||||
string fileSystemClass = typeof(DefaultEditorFileSystem).FullName;
|
||||
var fileSystemParams = new FileSystemParameters(fileSystemClass, null);
|
||||
fileSystemParams.AddParameter("SIMULATE_BUILD_RESULT", simulateBuildResult);
|
||||
var fileSystemParams = new FileSystemParameters(fileSystemClass, simulateBuildResult.PackageRootDirectory);
|
||||
return fileSystemParams;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,14 +18,12 @@ namespace YooAsset
|
|||
None,
|
||||
CreateFileSystem,
|
||||
InitFileSystem,
|
||||
LoadManifestFile,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly EditorSimulateModeImpl _impl;
|
||||
private readonly EditorSimulateModeParameters _parameters;
|
||||
private FSInitializeFileSystemOperation _initFileSystemOp;
|
||||
private FSLoadPackageManifestOperation _loadPackageManifestOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal EditorSimulateModeInitializationOperation(EditorSimulateModeImpl impl, EditorSimulateModeParameters parameters)
|
||||
|
@ -71,37 +69,15 @@ namespace YooAsset
|
|||
return;
|
||||
|
||||
if (_initFileSystemOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.LoadManifestFile;
|
||||
}
|
||||
else
|
||||
{
|
||||
_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;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _loadPackageManifestOp.Error;
|
||||
Error = _initFileSystemOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,13 +93,13 @@ namespace YooAsset
|
|||
None,
|
||||
CreateFileSystem,
|
||||
InitFileSystem,
|
||||
LoadManifestFile,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly OfflinePlayModeImpl _impl;
|
||||
private readonly OfflinePlayModeParameters _parameters;
|
||||
private FSInitializeFileSystemOperation _initFileSystemOp;
|
||||
private FSRequestPackageVersionOperation _requestPackageVersionOp;
|
||||
private FSLoadPackageManifestOperation _loadPackageManifestOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
@ -173,37 +149,15 @@ namespace YooAsset
|
|||
return;
|
||||
|
||||
if (_initFileSystemOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.LoadManifestFile;
|
||||
}
|
||||
else
|
||||
{
|
||||
_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;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _loadPackageManifestOp.Error;
|
||||
Error = _initFileSystemOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,6 @@ namespace YooAsset
|
|||
{
|
||||
public class SimulateBuildResult
|
||||
{
|
||||
public string PackageVersionFilePath;
|
||||
public string PackageManifestFilePath;
|
||||
public string PackageHashFilePath;
|
||||
public string PackageRootDirectory;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue