mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-18 22:20:07 +00:00
Compare commits
18 Commits
2.2.2-prev
...
2.2.3-prev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d34d1117a0 | ||
|
|
a5f3767cbc | ||
|
|
3bdb339f54 | ||
|
|
22cb3c3942 | ||
|
|
e5f5241879 | ||
|
|
79ac231df2 | ||
|
|
b7b375092f | ||
|
|
f86ea04521 | ||
|
|
738c02f58f | ||
|
|
d017688416 | ||
|
|
6b56275f87 | ||
|
|
b89f00130e | ||
|
|
4f58c54eff | ||
|
|
9001be21ac | ||
|
|
0d5558f29f | ||
|
|
c6377ce544 | ||
|
|
07d34891ef | ||
|
|
ddce031ee5 |
@@ -2,6 +2,41 @@
|
|||||||
|
|
||||||
All notable changes to this package will be documented in this file.
|
All notable changes to this package will be documented in this file.
|
||||||
|
|
||||||
|
## [2.2.3-preview] - 2024-08-13
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- (#311) 修复了断点续传下载器极小概率报错 : “416 Range Not Satisfiable”
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
|
||||||
|
- 原生文件构建管线支持原生文件加密。
|
||||||
|
|
||||||
|
- HostPlayMode模式下内置文件系统初始化参数可以为空。
|
||||||
|
|
||||||
|
- 场景加载增加了LocalPhysicsMode参数来控制物理运行模式。
|
||||||
|
|
||||||
|
- 默认的内置文件系统和缓存文件系统增加解密方法。
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
/// <summary>
|
||||||
|
/// 创建默认的内置文件系统参数
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="decryptionServices">加密文件解密服务类</param>
|
||||||
|
/// <param name="verifyLevel">缓存文件的校验等级</param>
|
||||||
|
/// <param name="rootDirectory">内置文件的根路径</param>
|
||||||
|
public static FileSystemParameters CreateDefaultBuildinFileSystemParameters(IDecryptionServices decryptionServices, EFileVerifyLevel verifyLevel, string rootDirectory);
|
||||||
|
|
||||||
|
/// <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, EFileVerifyLevel verifyLevel, string rootDirectory);
|
||||||
|
```
|
||||||
|
|
||||||
## [2.2.2-preview] - 2024-07-31
|
## [2.2.2-preview] - 2024-07-31
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using System.IO;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskEncryption_BBP : TaskEncryption, IBuildTask
|
public class TaskEncryption_BBP : TaskEncryption, IBuildTask
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class TaskEncryption_RFBP : TaskEncryption, IBuildTask
|
||||||
|
{
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
|
||||||
|
var buildMode = buildParameters.Parameters.BuildMode;
|
||||||
|
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
||||||
|
{
|
||||||
|
EncryptingBundleFiles(buildParameters, buildMapContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b3e156139dcc25f4c9440ec3d6cb96d2
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -32,6 +32,7 @@ namespace YooAsset.Editor
|
|||||||
new TaskPrepare_RFBP(),
|
new TaskPrepare_RFBP(),
|
||||||
new TaskGetBuildMap_RFBP(),
|
new TaskGetBuildMap_RFBP(),
|
||||||
new TaskBuilding_RFBP(),
|
new TaskBuilding_RFBP(),
|
||||||
|
new TaskEncryption_RFBP(),
|
||||||
new TaskUpdateBundleInfo_RFBP(),
|
new TaskUpdateBundleInfo_RFBP(),
|
||||||
new TaskCreateManifest_RFBP(),
|
new TaskCreateManifest_RFBP(),
|
||||||
new TaskCreateReport_RFBP(),
|
new TaskCreateReport_RFBP(),
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using System.IO;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public class TaskEncryption_SBP : TaskEncryption, IBuildTask
|
public class TaskEncryption_SBP : TaskEncryption, IBuildTask
|
||||||
|
|||||||
@@ -98,6 +98,11 @@ namespace YooAsset
|
|||||||
/// 自定义参数:原生文件构建管线
|
/// 自定义参数:原生文件构建管线
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool RawFileBuildPipeline { private set; get; } = false;
|
public bool RawFileBuildPipeline { private set; get; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 自定义参数:解密方法类
|
||||||
|
/// </summary>
|
||||||
|
public IDecryptionServices DecryptionServices { private set; get; }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
@@ -172,8 +177,11 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_loadedStream.TryGetValue(bundle.BundleGUID, out Stream managedStream))
|
if (_loadedStream.TryGetValue(bundle.BundleGUID, out Stream managedStream))
|
||||||
{
|
{
|
||||||
managedStream.Close();
|
if (managedStream != null)
|
||||||
managedStream.Dispose();
|
{
|
||||||
|
managedStream.Close();
|
||||||
|
managedStream.Dispose();
|
||||||
|
}
|
||||||
_loadedStream.Remove(bundle.BundleGUID);
|
_loadedStream.Remove(bundle.BundleGUID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -181,18 +189,22 @@ namespace YooAsset
|
|||||||
|
|
||||||
public virtual void SetParameter(string name, object value)
|
public virtual void SetParameter(string name, object value)
|
||||||
{
|
{
|
||||||
if (name == "FILE_VERIFY_LEVEL")
|
if (name == FileSystemParametersDefine.FILE_VERIFY_LEVEL)
|
||||||
{
|
{
|
||||||
FileVerifyLevel = (EFileVerifyLevel)value;
|
FileVerifyLevel = (EFileVerifyLevel)value;
|
||||||
}
|
}
|
||||||
else if (name == "APPEND_FILE_EXTENSION")
|
else if (name == FileSystemParametersDefine.APPEND_FILE_EXTENSION)
|
||||||
{
|
{
|
||||||
AppendFileExtension = (bool)value;
|
AppendFileExtension = (bool)value;
|
||||||
}
|
}
|
||||||
else if (name == "RAW_FILE_BUILD_PIPELINE")
|
else if (name == FileSystemParametersDefine.RAW_FILE_BUILD_PIPELINE)
|
||||||
{
|
{
|
||||||
RawFileBuildPipeline = (bool)value;
|
RawFileBuildPipeline = (bool)value;
|
||||||
}
|
}
|
||||||
|
else if (name == FileSystemParametersDefine.DECRYPTION_SERVICES)
|
||||||
|
{
|
||||||
|
DecryptionServices = (IDecryptionServices)value;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
YooLogger.Warning($"Invalid parameter : {name}");
|
YooLogger.Warning($"Invalid parameter : {name}");
|
||||||
@@ -210,10 +222,11 @@ namespace YooAsset
|
|||||||
// 创建解压文件系统
|
// 创建解压文件系统
|
||||||
var remoteServices = new UnpackRemoteServices(_packageRoot);
|
var remoteServices = new UnpackRemoteServices(_packageRoot);
|
||||||
_unpackFileSystem = new DefaultUnpackFileSystem();
|
_unpackFileSystem = new DefaultUnpackFileSystem();
|
||||||
_unpackFileSystem.SetParameter("REMOTE_SERVICES", remoteServices);
|
_unpackFileSystem.SetParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices);
|
||||||
_unpackFileSystem.SetParameter("FILE_VERIFY_LEVEL", FileVerifyLevel);
|
_unpackFileSystem.SetParameter(FileSystemParametersDefine.FILE_VERIFY_LEVEL, FileVerifyLevel);
|
||||||
_unpackFileSystem.SetParameter("APPEND_FILE_EXTENSION", AppendFileExtension);
|
_unpackFileSystem.SetParameter(FileSystemParametersDefine.APPEND_FILE_EXTENSION, AppendFileExtension);
|
||||||
_unpackFileSystem.SetParameter("RAW_FILE_BUILD_PIPELINE", RawFileBuildPipeline);
|
_unpackFileSystem.SetParameter(FileSystemParametersDefine.RAW_FILE_BUILD_PIPELINE, RawFileBuildPipeline);
|
||||||
|
_unpackFileSystem.SetParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, DecryptionServices);
|
||||||
_unpackFileSystem.OnCreate(packageName, null);
|
_unpackFileSystem.OnCreate(packageName, null);
|
||||||
}
|
}
|
||||||
public virtual void OnUpdate()
|
public virtual void OnUpdate()
|
||||||
@@ -256,8 +269,28 @@ namespace YooAsset
|
|||||||
if (Exists(bundle) == false)
|
if (Exists(bundle) == false)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
string filePath = GetBuildinFileLoadPath(bundle);
|
if (bundle.Encrypted)
|
||||||
return FileUtility.ReadAllBytes(filePath);
|
{
|
||||||
|
if (DecryptionServices == null)
|
||||||
|
{
|
||||||
|
YooLogger.Error($"The {nameof(IDecryptionServices)} is null !");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
string filePath = GetBuildinFileLoadPath(bundle);
|
||||||
|
var fileInfo = new DecryptFileInfo()
|
||||||
|
{
|
||||||
|
BundleName = bundle.BundleName,
|
||||||
|
FileLoadCRC = bundle.UnityCRC,
|
||||||
|
FileLoadPath = filePath,
|
||||||
|
};
|
||||||
|
return DecryptionServices.ReadFileData(fileInfo);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string filePath = GetBuildinFileLoadPath(bundle);
|
||||||
|
return FileUtility.ReadAllBytes(filePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public virtual string ReadFileText(PackageBundle bundle)
|
public virtual string ReadFileText(PackageBundle bundle)
|
||||||
{
|
{
|
||||||
@@ -267,8 +300,28 @@ namespace YooAsset
|
|||||||
if (Exists(bundle) == false)
|
if (Exists(bundle) == false)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
string filePath = GetBuildinFileLoadPath(bundle);
|
if (bundle.Encrypted)
|
||||||
return FileUtility.ReadAllText(filePath);
|
{
|
||||||
|
if (DecryptionServices == null)
|
||||||
|
{
|
||||||
|
YooLogger.Error($"The {nameof(IDecryptionServices)} is null !");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
string filePath = GetBuildinFileLoadPath(bundle);
|
||||||
|
var fileInfo = new DecryptFileInfo()
|
||||||
|
{
|
||||||
|
BundleName = bundle.BundleName,
|
||||||
|
FileLoadCRC = bundle.UnityCRC,
|
||||||
|
FileLoadPath = filePath,
|
||||||
|
};
|
||||||
|
return DecryptionServices.ReadFileText(fileInfo);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string filePath = GetBuildinFileLoadPath(bundle);
|
||||||
|
return FileUtility.ReadAllText(filePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 内部方法
|
#region 内部方法
|
||||||
@@ -310,7 +363,7 @@ namespace YooAsset
|
|||||||
string rootPath = PathUtility.Combine(Application.dataPath, "StreamingAssets", YooAssetSettingsData.Setting.DefaultYooFolderName);
|
string rootPath = PathUtility.Combine(Application.dataPath, "StreamingAssets", YooAssetSettingsData.Setting.DefaultYooFolderName);
|
||||||
return PathUtility.Combine(rootPath, PackageName);
|
return PathUtility.Combine(rootPath, PackageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 记录文件信息
|
/// 记录文件信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -333,6 +386,42 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
return _unpackFileSystem.InitializeFileSystemAsync();
|
return _unpackFileSystem.InitializeFileSystemAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加载加密资源文件
|
||||||
|
/// </summary>
|
||||||
|
public AssetBundle LoadEncryptedAssetBundle(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
string filePath = GetBuildinFileLoadPath(bundle);
|
||||||
|
var fileInfo = new DecryptFileInfo()
|
||||||
|
{
|
||||||
|
BundleName = bundle.BundleName,
|
||||||
|
FileLoadCRC = bundle.UnityCRC,
|
||||||
|
FileLoadPath = filePath,
|
||||||
|
};
|
||||||
|
|
||||||
|
var assetBundle = DecryptionServices.LoadAssetBundle(fileInfo, out var managedStream);
|
||||||
|
_loadedStream.Add(bundle.BundleGUID, managedStream);
|
||||||
|
return assetBundle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加载加密资源文件
|
||||||
|
/// </summary>
|
||||||
|
public AssetBundleCreateRequest LoadEncryptedAssetBundleAsync(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
string filePath = GetBuildinFileLoadPath(bundle);
|
||||||
|
var fileInfo = new DecryptFileInfo()
|
||||||
|
{
|
||||||
|
BundleName = bundle.BundleName,
|
||||||
|
FileLoadCRC = bundle.UnityCRC,
|
||||||
|
FileLoadPath = filePath,
|
||||||
|
};
|
||||||
|
|
||||||
|
var createRequest = DecryptionServices.LoadAssetBundleAsync(fileInfo, out var managedStream);
|
||||||
|
_loadedStream.Add(bundle.BundleGUID, managedStream);
|
||||||
|
return createRequest;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,6 +15,8 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void OnPreprocessBuild(UnityEditor.Build.Reporting.BuildReport report)
|
public void OnPreprocessBuild(UnityEditor.Build.Reporting.BuildReport report)
|
||||||
{
|
{
|
||||||
|
YooLogger.Log("Begin to create catalog file !");
|
||||||
|
|
||||||
string savePath = $"Assets/Resources/{YooAssetSettingsData.Setting.DefaultYooFolderName}";
|
string savePath = $"Assets/Resources/{YooAssetSettingsData.Setting.DefaultYooFolderName}";
|
||||||
DirectoryInfo saveDirectory = new DirectoryInfo(savePath);
|
DirectoryInfo saveDirectory = new DirectoryInfo(savePath);
|
||||||
if (saveDirectory.Exists)
|
if (saveDirectory.Exists)
|
||||||
@@ -24,8 +26,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 StreamingAssets root directory : {rootPath}");
|
throw new System.Exception($"Can not found StreamingAssets root directory : {rootPath}");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 搜索所有Package目录
|
// 搜索所有Package目录
|
||||||
@@ -48,8 +49,7 @@ namespace YooAsset
|
|||||||
string versionFilePath = $"{pacakgeDirectory}/{versionFileName}";
|
string versionFilePath = $"{pacakgeDirectory}/{versionFileName}";
|
||||||
if (File.Exists(versionFilePath) == false)
|
if (File.Exists(versionFilePath) == false)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"Can not found package version file : {versionFilePath}");
|
throw new System.Exception($"Can not found package version file : {versionFilePath}");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
packageVersion = FileUtility.ReadAllText(versionFilePath);
|
packageVersion = FileUtility.ReadAllText(versionFilePath);
|
||||||
@@ -62,8 +62,7 @@ namespace YooAsset
|
|||||||
string manifestFilePath = $"{pacakgeDirectory}/{manifestFileName}";
|
string manifestFilePath = $"{pacakgeDirectory}/{manifestFileName}";
|
||||||
if (File.Exists(manifestFilePath) == false)
|
if (File.Exists(manifestFilePath) == false)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"Can not found package manifest file : {manifestFilePath}");
|
throw new System.Exception($"Can not found package manifest file : {manifestFilePath}");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var binaryData = FileUtility.ReadAllBytes(manifestFilePath);
|
var binaryData = FileUtility.ReadAllBytes(manifestFilePath);
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ namespace YooAsset
|
|||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
LoadBuidlinAssetBundle,
|
LoadAssetBundle,
|
||||||
CheckLoadBuildinResult,
|
CheckResult,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,28 +32,56 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
DownloadProgress = 1f;
|
DownloadProgress = 1f;
|
||||||
DownloadedBytes = _bundle.FileSize;
|
DownloadedBytes = _bundle.FileSize;
|
||||||
_steps = ESteps.LoadBuidlinAssetBundle;
|
_steps = ESteps.LoadAssetBundle;
|
||||||
}
|
}
|
||||||
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.LoadBuidlinAssetBundle)
|
if (_steps == ESteps.LoadAssetBundle)
|
||||||
{
|
{
|
||||||
string filePath = _fileSystem.GetBuildinFileLoadPath(_bundle);
|
if (_bundle.Encrypted)
|
||||||
|
{
|
||||||
|
if (_fileSystem.DecryptionServices == null)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"The {nameof(IDecryptionServices)} is null !";
|
||||||
|
YooLogger.Error(Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_isWaitForAsyncComplete)
|
if (_isWaitForAsyncComplete)
|
||||||
{
|
{
|
||||||
Result = AssetBundle.LoadFromFile(filePath);
|
if (_bundle.Encrypted)
|
||||||
|
{
|
||||||
|
Result = _fileSystem.LoadEncryptedAssetBundle(_bundle);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string filePath = _fileSystem.GetBuildinFileLoadPath(_bundle);
|
||||||
|
Result = AssetBundle.LoadFromFile(filePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_createRequest = AssetBundle.LoadFromFileAsync(filePath);
|
if (_bundle.Encrypted)
|
||||||
|
{
|
||||||
|
_createRequest = _fileSystem.LoadEncryptedAssetBundleAsync(_bundle);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string filePath = _fileSystem.GetBuildinFileLoadPath(_bundle);
|
||||||
|
_createRequest = AssetBundle.LoadFromFileAsync(filePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_steps = ESteps.CheckLoadBuildinResult;
|
|
||||||
|
_steps = ESteps.CheckResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.CheckLoadBuildinResult)
|
if (_steps == ESteps.CheckResult)
|
||||||
{
|
{
|
||||||
if (_createRequest != null)
|
if (_createRequest != null)
|
||||||
{
|
{
|
||||||
@@ -75,12 +103,22 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_bundle.Encrypted)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"Failed to load encrypted buildin asset bundle file : {_bundle.BundleName}";
|
||||||
|
YooLogger.Error(Error);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = $"Failed to load buildin asset bundle file : {_bundle.BundleName}";
|
Error = $"Failed to load buildin asset bundle file : {_bundle.BundleName}";
|
||||||
|
YooLogger.Error(Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -149,6 +187,7 @@ namespace YooAsset
|
|||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = $"Can not found buildin raw bundle file : {filePath}";
|
Error = $"Can not found buildin raw bundle file : {filePath}";
|
||||||
|
YooLogger.Error(Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,6 +97,11 @@ namespace YooAsset
|
|||||||
/// 自定义参数:断点续传下载器关注的错误码
|
/// 自定义参数:断点续传下载器关注的错误码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<long> ResumeDownloadResponseCodes { private set; get; } = null;
|
public List<long> ResumeDownloadResponseCodes { private set; get; } = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 自定义参数:解密方法类
|
||||||
|
/// </summary>
|
||||||
|
public IDecryptionServices DecryptionServices { private set; get; }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
@@ -200,38 +205,45 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_loadedStream.TryGetValue(bundle.BundleGUID, out Stream managedStream))
|
if (_loadedStream.TryGetValue(bundle.BundleGUID, out Stream managedStream))
|
||||||
{
|
{
|
||||||
managedStream.Close();
|
if (managedStream != null)
|
||||||
managedStream.Dispose();
|
{
|
||||||
|
managedStream.Close();
|
||||||
|
managedStream.Dispose();
|
||||||
|
}
|
||||||
_loadedStream.Remove(bundle.BundleGUID);
|
_loadedStream.Remove(bundle.BundleGUID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void SetParameter(string name, object value)
|
public virtual void SetParameter(string name, object value)
|
||||||
{
|
{
|
||||||
if (name == "REMOTE_SERVICES")
|
if (name == FileSystemParametersDefine.REMOTE_SERVICES)
|
||||||
{
|
{
|
||||||
RemoteServices = (IRemoteServices)value;
|
RemoteServices = (IRemoteServices)value;
|
||||||
}
|
}
|
||||||
else if (name == "FILE_VERIFY_LEVEL")
|
else if (name == FileSystemParametersDefine.FILE_VERIFY_LEVEL)
|
||||||
{
|
{
|
||||||
FileVerifyLevel = (EFileVerifyLevel)value;
|
FileVerifyLevel = (EFileVerifyLevel)value;
|
||||||
}
|
}
|
||||||
else if (name == "APPEND_FILE_EXTENSION")
|
else if (name == FileSystemParametersDefine.APPEND_FILE_EXTENSION)
|
||||||
{
|
{
|
||||||
AppendFileExtension = (bool)value;
|
AppendFileExtension = (bool)value;
|
||||||
}
|
}
|
||||||
else if (name == "RAW_FILE_BUILD_PIPELINE")
|
else if (name == FileSystemParametersDefine.RAW_FILE_BUILD_PIPELINE)
|
||||||
{
|
{
|
||||||
RawFileBuildPipeline = (bool)value;
|
RawFileBuildPipeline = (bool)value;
|
||||||
}
|
}
|
||||||
else if (name == "RESUME_DOWNLOAD_MINMUM_SIZE")
|
else if (name == FileSystemParametersDefine.RESUME_DOWNLOAD_MINMUM_SIZE)
|
||||||
{
|
{
|
||||||
ResumeDownloadMinimumSize = (long)value;
|
ResumeDownloadMinimumSize = (long)value;
|
||||||
}
|
}
|
||||||
else if (name == "RESUME_DOWNLOAD_RESPONSE_CODES")
|
else if (name == FileSystemParametersDefine.RESUME_DOWNLOAD_RESPONSE_CODES)
|
||||||
{
|
{
|
||||||
ResumeDownloadResponseCodes = (List<long>)value;
|
ResumeDownloadResponseCodes = (List<long>)value;
|
||||||
}
|
}
|
||||||
|
else if (name == FileSystemParametersDefine.DECRYPTION_SERVICES)
|
||||||
|
{
|
||||||
|
DecryptionServices = (IDecryptionServices)value;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
YooLogger.Warning($"Invalid parameter : {name}");
|
YooLogger.Warning($"Invalid parameter : {name}");
|
||||||
@@ -308,16 +320,56 @@ namespace YooAsset
|
|||||||
if (Exists(bundle) == false)
|
if (Exists(bundle) == false)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
string filePath = GetCacheFileLoadPath(bundle);
|
if (bundle.Encrypted)
|
||||||
return FileUtility.ReadAllBytes(filePath);
|
{
|
||||||
|
if (DecryptionServices == null)
|
||||||
|
{
|
||||||
|
YooLogger.Error($"The {nameof(IDecryptionServices)} is null !");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
string filePath = GetCacheFileLoadPath(bundle);
|
||||||
|
var fileInfo = new DecryptFileInfo()
|
||||||
|
{
|
||||||
|
BundleName = bundle.BundleName,
|
||||||
|
FileLoadCRC = bundle.UnityCRC,
|
||||||
|
FileLoadPath = filePath,
|
||||||
|
};
|
||||||
|
return DecryptionServices.ReadFileData(fileInfo);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string filePath = GetCacheFileLoadPath(bundle);
|
||||||
|
return FileUtility.ReadAllBytes(filePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public virtual string ReadFileText(PackageBundle bundle)
|
public virtual string ReadFileText(PackageBundle bundle)
|
||||||
{
|
{
|
||||||
if (Exists(bundle) == false)
|
if (Exists(bundle) == false)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
string filePath = GetCacheFileLoadPath(bundle);
|
if (bundle.Encrypted)
|
||||||
return FileUtility.ReadAllText(filePath);
|
{
|
||||||
|
if (DecryptionServices == null)
|
||||||
|
{
|
||||||
|
YooLogger.Error($"The {nameof(IDecryptionServices)} is null !");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
string filePath = GetCacheFileLoadPath(bundle);
|
||||||
|
var fileInfo = new DecryptFileInfo()
|
||||||
|
{
|
||||||
|
BundleName = bundle.BundleName,
|
||||||
|
FileLoadCRC = bundle.UnityCRC,
|
||||||
|
FileLoadPath = filePath,
|
||||||
|
};
|
||||||
|
return DecryptionServices.ReadFileText(fileInfo);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string filePath = GetCacheFileLoadPath(bundle);
|
||||||
|
return FileUtility.ReadAllText(filePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 内部方法
|
#region 内部方法
|
||||||
@@ -528,6 +580,42 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
return _wrappers.Keys.ToList();
|
return _wrappers.Keys.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加载加密资源文件
|
||||||
|
/// </summary>
|
||||||
|
public AssetBundle LoadEncryptedAssetBundle(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
string filePath = GetCacheFileLoadPath(bundle);
|
||||||
|
var fileInfo = new DecryptFileInfo()
|
||||||
|
{
|
||||||
|
BundleName = bundle.BundleName,
|
||||||
|
FileLoadCRC = bundle.UnityCRC,
|
||||||
|
FileLoadPath = filePath,
|
||||||
|
};
|
||||||
|
|
||||||
|
var assetBundle = DecryptionServices.LoadAssetBundle(fileInfo, out var managedStream);
|
||||||
|
_loadedStream.Add(bundle.BundleGUID, managedStream);
|
||||||
|
return assetBundle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加载加密资源文件
|
||||||
|
/// </summary>
|
||||||
|
public AssetBundleCreateRequest LoadEncryptedAssetBundleAsync(PackageBundle bundle)
|
||||||
|
{
|
||||||
|
string filePath = GetCacheFileLoadPath(bundle);
|
||||||
|
var fileInfo = new DecryptFileInfo()
|
||||||
|
{
|
||||||
|
BundleName = bundle.BundleName,
|
||||||
|
FileLoadCRC = bundle.UnityCRC,
|
||||||
|
FileLoadPath = filePath,
|
||||||
|
};
|
||||||
|
|
||||||
|
var createRequest = DecryptionServices.LoadAssetBundleAsync(fileInfo, out var managedStream);
|
||||||
|
_loadedStream.Add(bundle.BundleGUID, managedStream);
|
||||||
|
return createRequest;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -250,17 +250,17 @@ namespace YooAsset
|
|||||||
if (File.Exists(_tempFilePath))
|
if (File.Exists(_tempFilePath))
|
||||||
{
|
{
|
||||||
FileInfo fileInfo = new FileInfo(_tempFilePath);
|
FileInfo fileInfo = new FileInfo(_tempFilePath);
|
||||||
fileBeginLength = fileInfo.Length;
|
if (fileInfo.Length >= Bundle.FileSize)
|
||||||
_fileOriginLength = fileBeginLength;
|
{
|
||||||
DownloadedBytes = _fileOriginLength;
|
// 删除临时文件
|
||||||
}
|
|
||||||
|
|
||||||
// 检测下载起始位置
|
|
||||||
if (fileBeginLength >= Bundle.FileSize)
|
|
||||||
{
|
|
||||||
// 删除临时文件
|
|
||||||
if (File.Exists(_tempFilePath))
|
|
||||||
File.Delete(_tempFilePath);
|
File.Delete(_tempFilePath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fileBeginLength = fileInfo.Length;
|
||||||
|
_fileOriginLength = fileBeginLength;
|
||||||
|
DownloadedBytes = _fileOriginLength;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建下载器
|
// 创建下载器
|
||||||
|
|||||||
@@ -78,15 +78,43 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.LoadAssetBundle)
|
if (_steps == ESteps.LoadAssetBundle)
|
||||||
{
|
{
|
||||||
string filePath = _fileSystem.GetCacheFileLoadPath(_bundle);
|
if (_bundle.Encrypted)
|
||||||
|
{
|
||||||
|
if (_fileSystem.DecryptionServices == null)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"The {nameof(IDecryptionServices)} is null !";
|
||||||
|
YooLogger.Error(Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_isWaitForAsyncComplete)
|
if (_isWaitForAsyncComplete)
|
||||||
{
|
{
|
||||||
Result = AssetBundle.LoadFromFile(filePath);
|
if (_bundle.Encrypted)
|
||||||
|
{
|
||||||
|
Result = _fileSystem.LoadEncryptedAssetBundle(_bundle);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string filePath = _fileSystem.GetCacheFileLoadPath(_bundle);
|
||||||
|
Result = AssetBundle.LoadFromFile(filePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_createRequest = AssetBundle.LoadFromFileAsync(filePath);
|
if (_bundle.Encrypted)
|
||||||
|
{
|
||||||
|
_createRequest = _fileSystem.LoadEncryptedAssetBundleAsync(_bundle);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string filePath = _fileSystem.GetCacheFileLoadPath(_bundle);
|
||||||
|
_createRequest = AssetBundle.LoadFromFileAsync(filePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_steps = ESteps.CheckResult;
|
_steps = ESteps.CheckResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,51 +140,59 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
// 注意:当缓存文件的校验等级为Low的时候,并不能保证缓存文件的完整性。
|
||||||
|
// 说明:在AssetBundle文件加载失败的情况下,我们需要重新验证文件的完整性!
|
||||||
|
EFileVerifyResult verifyResult = _fileSystem.VerifyCacheFile(_bundle);
|
||||||
|
if (verifyResult == EFileVerifyResult.Succeed)
|
||||||
{
|
{
|
||||||
// 注意:当缓存文件的校验等级为Low的时候,并不能保证缓存文件的完整性。
|
if (_bundle.Encrypted)
|
||||||
// 说明:在AssetBundle文件加载失败的情况下,我们需要重新验证文件的完整性!
|
|
||||||
EFileVerifyResult verifyResult = _fileSystem.VerifyCacheFile(_bundle);
|
|
||||||
if (verifyResult == EFileVerifyResult.Succeed)
|
|
||||||
{
|
{
|
||||||
// 注意:在安卓移动平台,华为和三星真机上有极小概率加载资源包失败。
|
_steps = ESteps.Done;
|
||||||
// 说明:大多数情况在首次安装下载资源到沙盒内,游戏过程中切换到后台再回到游戏内有很大概率触发!
|
Status = EOperationStatus.Failed;
|
||||||
string filePath = _fileSystem.GetCacheFileLoadPath(_bundle);
|
Error = $"Failed to load encrypted asset bundle file : {_bundle.BundleName}";
|
||||||
byte[] fileData = FileUtility.ReadAllBytes(filePath);
|
YooLogger.Error(Error);
|
||||||
if (fileData != null && fileData.Length > 0)
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 注意:在安卓移动平台,华为和三星真机上有极小概率加载资源包失败。
|
||||||
|
// 说明:大多数情况在首次安装下载资源到沙盒内,游戏过程中切换到后台再回到游戏内有很大概率触发!
|
||||||
|
string filePath = _fileSystem.GetCacheFileLoadPath(_bundle);
|
||||||
|
byte[] fileData = FileUtility.ReadAllBytes(filePath);
|
||||||
|
if (fileData != null && fileData.Length > 0)
|
||||||
|
{
|
||||||
|
Result = AssetBundle.LoadFromMemory(fileData);
|
||||||
|
if (Result == null)
|
||||||
{
|
{
|
||||||
Result = AssetBundle.LoadFromMemory(fileData);
|
_steps = ESteps.Done;
|
||||||
if (Result == null)
|
Status = EOperationStatus.Failed;
|
||||||
{
|
Error = $"Failed to load asset bundle from memory : {_bundle.BundleName}";
|
||||||
_steps = ESteps.Done;
|
YooLogger.Error(Error);
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = $"Failed to load assetBundle from memory : {_bundle.BundleName}";
|
|
||||||
YooLogger.Error(Error);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Succeed;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Succeed;
|
||||||
Error = $"Failed to read assetBundle file bytes : {_bundle.BundleName}";
|
|
||||||
YooLogger.Error(Error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
_fileSystem.DeleteCacheFile(_bundle.BundleGUID);
|
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = $"Find corrupted file and delete the file : {_bundle.BundleName}";
|
Error = $"Failed to read asset bundle file bytes : {_bundle.BundleName}";
|
||||||
YooLogger.Error(Error);
|
YooLogger.Error(Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
_fileSystem.DeleteCacheFile(_bundle.BundleGUID);
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"Find corrupted asset bundle file and delete : {_bundle.BundleName}";
|
||||||
|
YooLogger.Error(Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internal override void InternalWaitForAsyncComplete()
|
internal override void InternalWaitForAsyncComplete()
|
||||||
@@ -272,6 +308,7 @@ namespace YooAsset
|
|||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = $"Can not found cache raw bundle file : {filePath}";
|
Error = $"Can not found cache raw bundle file : {filePath}";
|
||||||
|
YooLogger.Error(Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
public virtual void SetParameter(string name, object value)
|
public virtual void SetParameter(string name, object value)
|
||||||
{
|
{
|
||||||
if (name == "DISABLE_UNITY_WEB_CACHE")
|
if (name == FileSystemParametersDefine.DISABLE_UNITY_WEB_CACHE)
|
||||||
{
|
{
|
||||||
DisableUnityWebCache = (bool)value;
|
DisableUnityWebCache = (bool)value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
internal class FileSystemParametersDefine
|
||||||
|
{
|
||||||
|
public const string FILE_VERIFY_LEVEL = "FILE_VERIFY_LEVEL";
|
||||||
|
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 RAW_FILE_BUILD_PIPELINE = "RAW_FILE_BUILD_PIPELINE";
|
||||||
|
public const string DISABLE_UNITY_WEB_CACHE = "DISABLE_UNITY_WEB_CACHE";
|
||||||
|
public const string RESUME_DOWNLOAD_MINMUM_SIZE = "RESUME_DOWNLOAD_MINMUM_SIZE";
|
||||||
|
public const string RESUME_DOWNLOAD_RESPONSE_CODES = "RESUME_DOWNLOAD_RESPONSE_CODES";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6b83a734e8baddb46aa731ee31fe988d
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -99,28 +99,32 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建默认的内置文件系统参数
|
/// 创建默认的内置文件系统参数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="decryptionServices">加密文件解密服务类</param>
|
||||||
/// <param name="verifyLevel">缓存文件的校验等级</param>
|
/// <param name="verifyLevel">缓存文件的校验等级</param>
|
||||||
/// <param name="rootDirectory">内置文件的根路径</param>
|
/// <param name="rootDirectory">内置文件的根路径</param>
|
||||||
public static FileSystemParameters CreateDefaultBuildinFileSystemParameters(EFileVerifyLevel verifyLevel = EFileVerifyLevel.Middle, string rootDirectory = null)
|
public static FileSystemParameters CreateDefaultBuildinFileSystemParameters(IDecryptionServices decryptionServices = null, EFileVerifyLevel verifyLevel = EFileVerifyLevel.Middle, string rootDirectory = null)
|
||||||
{
|
{
|
||||||
string fileSystemClass = typeof(DefaultBuildinFileSystem).FullName;
|
string fileSystemClass = typeof(DefaultBuildinFileSystem).FullName;
|
||||||
var fileSystemParams = new FileSystemParameters(fileSystemClass, rootDirectory);
|
var fileSystemParams = new FileSystemParameters(fileSystemClass, rootDirectory);
|
||||||
fileSystemParams.AddParameter("FILE_VERIFY_LEVEL", verifyLevel);
|
fileSystemParams.AddParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, decryptionServices);
|
||||||
|
fileSystemParams.AddParameter(FileSystemParametersDefine.FILE_VERIFY_LEVEL, verifyLevel);
|
||||||
return fileSystemParams;
|
return fileSystemParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建默认的内置文件系统参数(原生文件)
|
/// 创建默认的内置文件系统参数(原生文件)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="decryptionServices">加密文件解密服务类</param>
|
||||||
/// <param name="verifyLevel">缓存文件的校验等级</param>
|
/// <param name="verifyLevel">缓存文件的校验等级</param>
|
||||||
/// <param name="rootDirectory">内置文件的根路径</param>
|
/// <param name="rootDirectory">内置文件的根路径</param>
|
||||||
public static FileSystemParameters CreateDefaultBuildinRawFileSystemParameters(EFileVerifyLevel verifyLevel = EFileVerifyLevel.Middle, string rootDirectory = null)
|
public static FileSystemParameters CreateDefaultBuildinRawFileSystemParameters(IDecryptionServices decryptionServices = null, EFileVerifyLevel verifyLevel = EFileVerifyLevel.Middle, string rootDirectory = null)
|
||||||
{
|
{
|
||||||
string fileSystemClass = typeof(DefaultBuildinFileSystem).FullName;
|
string fileSystemClass = typeof(DefaultBuildinFileSystem).FullName;
|
||||||
var fileSystemParams = new FileSystemParameters(fileSystemClass, rootDirectory);
|
var fileSystemParams = new FileSystemParameters(fileSystemClass, rootDirectory);
|
||||||
fileSystemParams.AddParameter("FILE_VERIFY_LEVEL", verifyLevel);
|
fileSystemParams.AddParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, decryptionServices);
|
||||||
fileSystemParams.AddParameter("APPEND_FILE_EXTENSION", true);
|
fileSystemParams.AddParameter(FileSystemParametersDefine.FILE_VERIFY_LEVEL, verifyLevel);
|
||||||
fileSystemParams.AddParameter("RAW_FILE_BUILD_PIPELINE", true);
|
fileSystemParams.AddParameter(FileSystemParametersDefine.APPEND_FILE_EXTENSION, true);
|
||||||
|
fileSystemParams.AddParameter(FileSystemParametersDefine.RAW_FILE_BUILD_PIPELINE, true);
|
||||||
return fileSystemParams;
|
return fileSystemParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,14 +132,16 @@ namespace YooAsset
|
|||||||
/// 创建默认的缓存文件系统参数
|
/// 创建默认的缓存文件系统参数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="remoteServices">远端资源地址查询服务类</param>
|
/// <param name="remoteServices">远端资源地址查询服务类</param>
|
||||||
|
/// <param name="decryptionServices">加密文件解密服务类</param>
|
||||||
/// <param name="verifyLevel">缓存文件的校验等级</param>
|
/// <param name="verifyLevel">缓存文件的校验等级</param>
|
||||||
/// <param name="rootDirectory">文件系统的根目录</param>
|
/// <param name="rootDirectory">文件系统的根目录</param>
|
||||||
public static FileSystemParameters CreateDefaultCacheFileSystemParameters(IRemoteServices remoteServices, EFileVerifyLevel verifyLevel = EFileVerifyLevel.Middle, string rootDirectory = null)
|
public static FileSystemParameters CreateDefaultCacheFileSystemParameters(IRemoteServices remoteServices, IDecryptionServices decryptionServices = null, EFileVerifyLevel verifyLevel = EFileVerifyLevel.Middle, string rootDirectory = null)
|
||||||
{
|
{
|
||||||
string fileSystemClass = typeof(DefaultCacheFileSystem).FullName;
|
string fileSystemClass = typeof(DefaultCacheFileSystem).FullName;
|
||||||
var fileSystemParams = new FileSystemParameters(fileSystemClass, rootDirectory);
|
var fileSystemParams = new FileSystemParameters(fileSystemClass, rootDirectory);
|
||||||
fileSystemParams.AddParameter("REMOTE_SERVICES", remoteServices);
|
fileSystemParams.AddParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices);
|
||||||
fileSystemParams.AddParameter("FILE_VERIFY_LEVEL", verifyLevel);
|
fileSystemParams.AddParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, decryptionServices);
|
||||||
|
fileSystemParams.AddParameter(FileSystemParametersDefine.FILE_VERIFY_LEVEL, verifyLevel);
|
||||||
return fileSystemParams;
|
return fileSystemParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,16 +149,18 @@ namespace YooAsset
|
|||||||
/// 创建默认的缓存文件系统参数(原生文件)
|
/// 创建默认的缓存文件系统参数(原生文件)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="remoteServices">远端资源地址查询服务类</param>
|
/// <param name="remoteServices">远端资源地址查询服务类</param>
|
||||||
|
/// <param name="decryptionServices">加密文件解密服务类</param>
|
||||||
/// <param name="verifyLevel">缓存文件的校验等级</param>
|
/// <param name="verifyLevel">缓存文件的校验等级</param>
|
||||||
/// <param name="rootDirectory">文件系统的根目录</param>
|
/// <param name="rootDirectory">文件系统的根目录</param>
|
||||||
public static FileSystemParameters CreateDefaultCacheRawFileSystemParameters(IRemoteServices remoteServices, EFileVerifyLevel verifyLevel = EFileVerifyLevel.Middle, string rootDirectory = null)
|
public static FileSystemParameters CreateDefaultCacheRawFileSystemParameters(IRemoteServices remoteServices, IDecryptionServices decryptionServices = null, EFileVerifyLevel verifyLevel = EFileVerifyLevel.Middle, string rootDirectory = null)
|
||||||
{
|
{
|
||||||
string fileSystemClass = typeof(DefaultCacheFileSystem).FullName;
|
string fileSystemClass = typeof(DefaultCacheFileSystem).FullName;
|
||||||
var fileSystemParams = new FileSystemParameters(fileSystemClass, rootDirectory);
|
var fileSystemParams = new FileSystemParameters(fileSystemClass, rootDirectory);
|
||||||
fileSystemParams.AddParameter("REMOTE_SERVICES", remoteServices);
|
fileSystemParams.AddParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices);
|
||||||
fileSystemParams.AddParameter("FILE_VERIFY_LEVEL", verifyLevel);
|
fileSystemParams.AddParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, decryptionServices);
|
||||||
fileSystemParams.AddParameter("APPEND_FILE_EXTENSION", true);
|
fileSystemParams.AddParameter(FileSystemParametersDefine.FILE_VERIFY_LEVEL, verifyLevel);
|
||||||
fileSystemParams.AddParameter("RAW_FILE_BUILD_PIPELINE", true);
|
fileSystemParams.AddParameter(FileSystemParametersDefine.APPEND_FILE_EXTENSION, true);
|
||||||
|
fileSystemParams.AddParameter(FileSystemParametersDefine.RAW_FILE_BUILD_PIPELINE, true);
|
||||||
return fileSystemParams;
|
return fileSystemParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,7 +172,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
string fileSystemClass = typeof(DefaultWebFileSystem).FullName;
|
string fileSystemClass = typeof(DefaultWebFileSystem).FullName;
|
||||||
var fileSystemParams = new FileSystemParameters(fileSystemClass, null);
|
var fileSystemParams = new FileSystemParameters(fileSystemClass, null);
|
||||||
fileSystemParams.AddParameter("DISABLE_UNITY_WEB_CACHE", disableUnityWebCache);
|
fileSystemParams.AddParameter(FileSystemParametersDefine.DISABLE_UNITY_WEB_CACHE, disableUnityWebCache);
|
||||||
return fileSystemParams;
|
return fileSystemParams;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,6 +152,14 @@ namespace YooAsset
|
|||||||
return IsDone;
|
return IsDone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清空完成回调
|
||||||
|
/// </summary>
|
||||||
|
protected void ClearCompletedCallback()
|
||||||
|
{
|
||||||
|
_callback = null;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 等待异步执行完毕
|
/// 等待异步执行完毕
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
OnAbort();
|
OnAbort();
|
||||||
}
|
}
|
||||||
|
internal override void InternalWaitForAsyncComplete()
|
||||||
|
{
|
||||||
|
OnWaitForAsyncComplete();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步操作开始
|
/// 异步操作开始
|
||||||
@@ -31,6 +35,11 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected abstract void OnAbort();
|
protected abstract void OnAbort();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异步等待完成
|
||||||
|
/// </summary>
|
||||||
|
protected virtual void OnWaitForAsyncComplete() { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步操作系统是否繁忙
|
/// 异步操作系统是否繁忙
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace YooAsset
|
|||||||
add
|
add
|
||||||
{
|
{
|
||||||
if (IsValidWithWarning == false)
|
if (IsValidWithWarning == false)
|
||||||
throw new System.Exception($"{nameof(SceneHandle)} is invalid");
|
throw new System.Exception($"{nameof(SceneHandle)} is invalid !");
|
||||||
if (Provider.IsDone)
|
if (Provider.IsDone)
|
||||||
value.Invoke(this);
|
value.Invoke(this);
|
||||||
else
|
else
|
||||||
@@ -32,7 +32,7 @@ namespace YooAsset
|
|||||||
remove
|
remove
|
||||||
{
|
{
|
||||||
if (IsValidWithWarning == false)
|
if (IsValidWithWarning == false)
|
||||||
throw new System.Exception($"{nameof(SceneHandle)} is invalid");
|
throw new System.Exception($"{nameof(SceneHandle)} is invalid !");
|
||||||
_callback -= value;
|
_callback -= value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -168,13 +168,12 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 卸载子场景
|
// 卸载子场景
|
||||||
|
// 注意:如果场景正在加载过程,必须等待加载完成后才可以卸载该场景。
|
||||||
{
|
{
|
||||||
var operation = new UnloadSceneOperation(Provider);
|
var operation = new UnloadSceneOperation(Provider);
|
||||||
OperationSystem.StartOperation(packageName, operation);
|
OperationSystem.StartOperation(packageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,14 +14,13 @@ namespace YooAsset
|
|||||||
CheckError,
|
CheckError,
|
||||||
PrepareDone,
|
PrepareDone,
|
||||||
UnLoadScene,
|
UnLoadScene,
|
||||||
Checking,
|
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
private readonly string _error;
|
private readonly string _error;
|
||||||
private readonly ProviderOperation _provider;
|
private readonly ProviderOperation _provider;
|
||||||
private AsyncOperation _asyncOp;
|
private AsyncOperation _asyncOp = null;
|
||||||
|
|
||||||
internal UnloadSceneOperation(string error)
|
internal UnloadSceneOperation(string error)
|
||||||
{
|
{
|
||||||
@@ -96,16 +95,16 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.UnLoadScene)
|
if (_steps == ESteps.UnLoadScene)
|
||||||
{
|
{
|
||||||
_asyncOp = SceneManager.UnloadSceneAsync(_provider.SceneObject);
|
if (_asyncOp == null)
|
||||||
_provider.ResourceMgr.UnloadSubScene(_provider.SceneName);
|
{
|
||||||
_steps = ESteps.Checking;
|
_asyncOp = SceneManager.UnloadSceneAsync(_provider.SceneObject);
|
||||||
}
|
_provider.ResourceMgr.UnloadSubScene(_provider.SceneName);
|
||||||
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.Checking)
|
|
||||||
{
|
|
||||||
Progress = _asyncOp.progress;
|
Progress = _asyncOp.progress;
|
||||||
if (_asyncOp.isDone == false)
|
if (_asyncOp.isDone == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_provider.ResourceMgr.TryUnloadUnusedAsset(_provider.MainAssetInfo);
|
_provider.ResourceMgr.TryUnloadUnusedAsset(_provider.MainAssetInfo);
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
|
|||||||
@@ -8,13 +8,24 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
internal sealed class BundledSceneProvider : ProviderOperation
|
internal sealed class BundledSceneProvider : ProviderOperation
|
||||||
{
|
{
|
||||||
public readonly LoadSceneMode SceneMode;
|
public readonly LoadSceneParameters LoadSceneParams;
|
||||||
private AsyncOperation _asyncOperation;
|
private AsyncOperation _asyncOperation;
|
||||||
private bool _suspendLoadMode;
|
private bool _suspendLoadMode;
|
||||||
|
|
||||||
public BundledSceneProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo, LoadSceneMode sceneMode, bool suspendLoad) : base(manager, providerGUID, assetInfo)
|
/// <summary>
|
||||||
|
/// 场景加载模式
|
||||||
|
/// </summary>
|
||||||
|
public LoadSceneMode SceneMode
|
||||||
{
|
{
|
||||||
SceneMode = sceneMode;
|
get
|
||||||
|
{
|
||||||
|
return LoadSceneParams.loadSceneMode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public BundledSceneProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo, LoadSceneParameters loadSceneParams, bool suspendLoad) : base(manager, providerGUID, assetInfo)
|
||||||
|
{
|
||||||
|
LoadSceneParams = loadSceneParams;
|
||||||
SceneName = Path.GetFileNameWithoutExtension(assetInfo.AssetPath);
|
SceneName = Path.GetFileNameWithoutExtension(assetInfo.AssetPath);
|
||||||
_suspendLoadMode = suspendLoad;
|
_suspendLoadMode = suspendLoad;
|
||||||
}
|
}
|
||||||
@@ -61,15 +72,14 @@ namespace YooAsset
|
|||||||
if (IsWaitForAsyncComplete)
|
if (IsWaitForAsyncComplete)
|
||||||
{
|
{
|
||||||
// 注意:场景同步加载方法不会立即加载场景,而是在下一帧加载。
|
// 注意:场景同步加载方法不会立即加载场景,而是在下一帧加载。
|
||||||
LoadSceneParameters parameters = new LoadSceneParameters(SceneMode);
|
SceneObject = SceneManager.LoadScene(MainAssetInfo.AssetPath, LoadSceneParams);
|
||||||
SceneObject = SceneManager.LoadScene(MainAssetInfo.AssetPath, parameters);
|
|
||||||
_steps = ESteps.Checking;
|
_steps = ESteps.Checking;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 注意:如果场景不存在异步加载方法返回NULL
|
// 注意:如果场景不存在异步加载方法返回NULL
|
||||||
// 注意:即使是异步加载也要在当帧获取到场景对象
|
// 注意:即使是异步加载也要在当帧获取到场景对象
|
||||||
_asyncOperation = SceneManager.LoadSceneAsync(MainAssetInfo.AssetPath, SceneMode);
|
_asyncOperation = SceneManager.LoadSceneAsync(MainAssetInfo.AssetPath, LoadSceneParams);
|
||||||
if (_asyncOperation != null)
|
if (_asyncOperation != null)
|
||||||
{
|
{
|
||||||
_asyncOperation.allowSceneActivation = !_suspendLoadMode;
|
_asyncOperation.allowSceneActivation = !_suspendLoadMode;
|
||||||
|
|||||||
@@ -8,13 +8,24 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
internal sealed class DatabaseSceneProvider : ProviderOperation
|
internal sealed class DatabaseSceneProvider : ProviderOperation
|
||||||
{
|
{
|
||||||
public readonly LoadSceneMode SceneMode;
|
public readonly LoadSceneParameters LoadSceneParams;
|
||||||
private bool _suspendLoadMode;
|
|
||||||
private AsyncOperation _asyncOperation;
|
private AsyncOperation _asyncOperation;
|
||||||
|
private bool _suspendLoadMode;
|
||||||
|
|
||||||
public DatabaseSceneProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo, LoadSceneMode sceneMode, bool suspendLoad) : base(manager, providerGUID, assetInfo)
|
/// <summary>
|
||||||
|
/// 场景加载模式
|
||||||
|
/// </summary>
|
||||||
|
public LoadSceneMode SceneMode
|
||||||
{
|
{
|
||||||
SceneMode = sceneMode;
|
get
|
||||||
|
{
|
||||||
|
return LoadSceneParams.loadSceneMode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DatabaseSceneProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo, LoadSceneParameters loadSceneParams, bool suspendLoad) : base(manager, providerGUID, assetInfo)
|
||||||
|
{
|
||||||
|
LoadSceneParams = loadSceneParams;
|
||||||
SceneName = Path.GetFileNameWithoutExtension(assetInfo.AssetPath);
|
SceneName = Path.GetFileNameWithoutExtension(assetInfo.AssetPath);
|
||||||
_suspendLoadMode = suspendLoad;
|
_suspendLoadMode = suspendLoad;
|
||||||
}
|
}
|
||||||
@@ -53,14 +64,12 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
if (IsWaitForAsyncComplete)
|
if (IsWaitForAsyncComplete)
|
||||||
{
|
{
|
||||||
LoadSceneParameters loadSceneParameters = new LoadSceneParameters(SceneMode);
|
SceneObject = UnityEditor.SceneManagement.EditorSceneManager.LoadSceneInPlayMode(MainAssetInfo.AssetPath, LoadSceneParams);
|
||||||
SceneObject = UnityEditor.SceneManagement.EditorSceneManager.LoadSceneInPlayMode(MainAssetInfo.AssetPath, loadSceneParameters);
|
|
||||||
_steps = ESteps.Checking;
|
_steps = ESteps.Checking;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LoadSceneParameters loadSceneParameters = new LoadSceneParameters(SceneMode);
|
_asyncOperation = UnityEditor.SceneManagement.EditorSceneManager.LoadSceneAsyncInPlayMode(MainAssetInfo.AssetPath, LoadSceneParams);
|
||||||
_asyncOperation = UnityEditor.SceneManagement.EditorSceneManager.LoadSceneAsyncInPlayMode(MainAssetInfo.AssetPath, loadSceneParameters);
|
|
||||||
if (_asyncOperation != null)
|
if (_asyncOperation != null)
|
||||||
{
|
{
|
||||||
_asyncOperation.allowSceneActivation = !_suspendLoadMode;
|
_asyncOperation.allowSceneActivation = !_suspendLoadMode;
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ namespace YooAsset
|
|||||||
/// 注意:返回的场景句柄是唯一的,每个场景句柄对应自己的场景提供者对象。
|
/// 注意:返回的场景句柄是唯一的,每个场景句柄对应自己的场景提供者对象。
|
||||||
/// 注意:业务逻辑层应该避免同时加载一个子场景。
|
/// 注意:业务逻辑层应该避免同时加载一个子场景。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SceneHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode, bool suspendLoad, uint priority)
|
public SceneHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneParameters loadSceneParams, bool suspendLoad, uint priority)
|
||||||
{
|
{
|
||||||
if (assetInfo.IsInvalid)
|
if (assetInfo.IsInvalid)
|
||||||
{
|
{
|
||||||
@@ -97,7 +97,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 如果加载的是主场景,则卸载所有缓存的场景
|
// 如果加载的是主场景,则卸载所有缓存的场景
|
||||||
if (sceneMode == LoadSceneMode.Single)
|
if (loadSceneParams.loadSceneMode == LoadSceneMode.Single)
|
||||||
{
|
{
|
||||||
UnloadAllScene();
|
UnloadAllScene();
|
||||||
}
|
}
|
||||||
@@ -107,9 +107,9 @@ namespace YooAsset
|
|||||||
ProviderOperation provider;
|
ProviderOperation provider;
|
||||||
{
|
{
|
||||||
if (_simulationOnEditor)
|
if (_simulationOnEditor)
|
||||||
provider = new DatabaseSceneProvider(this, providerGUID, assetInfo, sceneMode, suspendLoad);
|
provider = new DatabaseSceneProvider(this, providerGUID, assetInfo, loadSceneParams, suspendLoad);
|
||||||
else
|
else
|
||||||
provider = new BundledSceneProvider(this, providerGUID, assetInfo, sceneMode, suspendLoad);
|
provider = new BundledSceneProvider(this, providerGUID, assetInfo, loadSceneParams, suspendLoad);
|
||||||
provider.InitSpawnDebugInfo();
|
provider.InitSpawnDebugInfo();
|
||||||
_providerDic.Add(providerGUID, provider);
|
_providerDic.Add(providerGUID, provider);
|
||||||
OperationSystem.StartOperation(PackageName, provider);
|
OperationSystem.StartOperation(PackageName, provider);
|
||||||
|
|||||||
@@ -45,6 +45,12 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.ClearFileSystemA)
|
if (_steps == ESteps.ClearFileSystemA)
|
||||||
{
|
{
|
||||||
|
if (_fileSystemA == null)
|
||||||
|
{
|
||||||
|
_steps = ESteps.ClearFileSystemB;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (_clearAllBundleFilesOpA == null)
|
if (_clearAllBundleFilesOpA == null)
|
||||||
_clearAllBundleFilesOpA = _fileSystemA.ClearAllBundleFilesAsync();
|
_clearAllBundleFilesOpA = _fileSystemA.ClearAllBundleFilesAsync();
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,12 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.ClearFileSystemA)
|
if (_steps == ESteps.ClearFileSystemA)
|
||||||
{
|
{
|
||||||
|
if (_fileSystemA == null)
|
||||||
|
{
|
||||||
|
_steps = ESteps.ClearFileSystemB;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (_clearUnusedBundleFilesOpA == null)
|
if (_clearUnusedBundleFilesOpA == null)
|
||||||
_clearUnusedBundleFilesOpA = _fileSystemA.ClearUnusedBundleFilesAsync(_impl.ActiveManifest);
|
_clearUnusedBundleFilesOpA = _fileSystemA.ClearUnusedBundleFilesAsync(_impl.ActiveManifest);
|
||||||
|
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ namespace YooAsset
|
|||||||
long downloadBytes = _cachedDownloadBytes;
|
long downloadBytes = _cachedDownloadBytes;
|
||||||
foreach (var downloader in _downloaders)
|
foreach (var downloader in _downloaders)
|
||||||
{
|
{
|
||||||
downloadBytes += (long)downloader.DownloadedBytes;
|
downloadBytes += downloader.DownloadedBytes;
|
||||||
if (downloader.IsDone == false)
|
if (downloader.IsDone == false)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ namespace YooAsset
|
|||||||
// 下载成功
|
// 下载成功
|
||||||
_removeList.Add(downloader);
|
_removeList.Add(downloader);
|
||||||
_cachedDownloadCount++;
|
_cachedDownloadCount++;
|
||||||
_cachedDownloadBytes += (long)downloader.DownloadedBytes;
|
_cachedDownloadBytes += downloader.DownloadedBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 移除已经完成的下载器(无论成功或失败)
|
// 移除已经完成的下载器(无论成功或失败)
|
||||||
|
|||||||
@@ -201,14 +201,6 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.CreateFileSystem)
|
if (_steps == ESteps.CreateFileSystem)
|
||||||
{
|
{
|
||||||
if (_parameters.BuildinFileSystemParameters == null)
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = "Buildin file system parameters is null";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_parameters.CacheFileSystemParameters == null)
|
if (_parameters.CacheFileSystemParameters == null)
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
@@ -217,6 +209,19 @@ namespace YooAsset
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_parameters.BuildinFileSystemParameters != null)
|
||||||
|
{
|
||||||
|
_impl.BuildinFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.BuildinFileSystemParameters);
|
||||||
|
if (_impl.BuildinFileSystem == null)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = "Failed to create buildin file system";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (_parameters.DeliveryFileSystemParameters != null)
|
if (_parameters.DeliveryFileSystemParameters != null)
|
||||||
{
|
{
|
||||||
_impl.DeliveryFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.DeliveryFileSystemParameters);
|
_impl.DeliveryFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.DeliveryFileSystemParameters);
|
||||||
@@ -229,15 +234,6 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_impl.BuildinFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.BuildinFileSystemParameters);
|
|
||||||
if (_impl.BuildinFileSystem == null)
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = "Failed to create buildin file system";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_impl.CacheFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.CacheFileSystemParameters);
|
_impl.CacheFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.CacheFileSystemParameters);
|
||||||
if (_impl.CacheFileSystem == null)
|
if (_impl.CacheFileSystem == null)
|
||||||
{
|
{
|
||||||
@@ -252,6 +248,13 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.InitBuildinFileSystem)
|
if (_steps == ESteps.InitBuildinFileSystem)
|
||||||
{
|
{
|
||||||
|
// 注意:内置文件系统可以为空
|
||||||
|
if (_impl.BuildinFileSystem == null)
|
||||||
|
{
|
||||||
|
_steps = ESteps.InitDeliveryFileSystem;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (_initBuildinFileSystemOp == null)
|
if (_initBuildinFileSystemOp == null)
|
||||||
_initBuildinFileSystemOp = _impl.BuildinFileSystem.InitializeFileSystemAsync();
|
_initBuildinFileSystemOp = _impl.BuildinFileSystem.InitializeFileSystemAsync();
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace YooAsset
|
|||||||
internal class HostPlayModeImpl : IPlayMode, IBundleQuery
|
internal class HostPlayModeImpl : IPlayMode, IBundleQuery
|
||||||
{
|
{
|
||||||
public readonly string PackageName;
|
public readonly string PackageName;
|
||||||
public IFileSystem BuildinFileSystem { set; get; }
|
public IFileSystem BuildinFileSystem { set; get; } //可以为空!
|
||||||
public IFileSystem DeliveryFileSystem { set; get; } //可以为空!
|
public IFileSystem DeliveryFileSystem { set; get; } //可以为空!
|
||||||
public IFileSystem CacheFileSystem { set; get; }
|
public IFileSystem CacheFileSystem { set; get; }
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ namespace YooAsset
|
|||||||
if (packageBundle == null)
|
if (packageBundle == null)
|
||||||
throw new Exception("Should never get here !");
|
throw new Exception("Should never get here !");
|
||||||
|
|
||||||
if (BuildinFileSystem.Belong(packageBundle))
|
if (BuildinFileSystem != null && BuildinFileSystem.Belong(packageBundle))
|
||||||
{
|
{
|
||||||
BundleInfo bundleInfo = new BundleInfo(BuildinFileSystem, packageBundle);
|
BundleInfo bundleInfo = new BundleInfo(BuildinFileSystem, packageBundle);
|
||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
|
|||||||
@@ -486,11 +486,12 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="location">场景的定位地址</param>
|
/// <param name="location">场景的定位地址</param>
|
||||||
/// <param name="sceneMode">场景加载模式</param>
|
/// <param name="sceneMode">场景加载模式</param>
|
||||||
public SceneHandle LoadSceneSync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single)
|
/// <param name="physicsMode">场景物理模式</param>
|
||||||
|
public SceneHandle LoadSceneSync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, LocalPhysicsMode physicsMode = LocalPhysicsMode.None)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
||||||
return LoadSceneInternal(assetInfo, true, sceneMode, false, 0);
|
return LoadSceneInternal(assetInfo, true, sceneMode, physicsMode, false, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -498,10 +499,11 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assetInfo">场景的资源信息</param>
|
/// <param name="assetInfo">场景的资源信息</param>
|
||||||
/// <param name="sceneMode">场景加载模式</param>
|
/// <param name="sceneMode">场景加载模式</param>
|
||||||
public SceneHandle LoadSceneSync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single)
|
/// <param name="physicsMode">场景物理模式</param>
|
||||||
|
public SceneHandle LoadSceneSync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, LocalPhysicsMode physicsMode = LocalPhysicsMode.None)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
return LoadSceneInternal(assetInfo, true, sceneMode, false, 0);
|
return LoadSceneInternal(assetInfo, true, sceneMode, physicsMode, false, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -509,13 +511,14 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="location">场景的定位地址</param>
|
/// <param name="location">场景的定位地址</param>
|
||||||
/// <param name="sceneMode">场景加载模式</param>
|
/// <param name="sceneMode">场景加载模式</param>
|
||||||
|
/// <param name="physicsMode">场景物理模式</param>
|
||||||
/// <param name="suspendLoad">场景加载到90%自动挂起</param>
|
/// <param name="suspendLoad">场景加载到90%自动挂起</param>
|
||||||
/// <param name="priority">加载的优先级</param>
|
/// <param name="priority">加载的优先级</param>
|
||||||
public SceneHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool suspendLoad = false, uint priority = 0)
|
public SceneHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, LocalPhysicsMode physicsMode = LocalPhysicsMode.None, bool suspendLoad = false, uint priority = 0)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
||||||
return LoadSceneInternal(assetInfo, false, sceneMode, suspendLoad, priority);
|
return LoadSceneInternal(assetInfo, false, sceneMode, physicsMode, suspendLoad, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -523,18 +526,20 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assetInfo">场景的资源信息</param>
|
/// <param name="assetInfo">场景的资源信息</param>
|
||||||
/// <param name="sceneMode">场景加载模式</param>
|
/// <param name="sceneMode">场景加载模式</param>
|
||||||
|
/// <param name="physicsMode">场景物理模式</param>
|
||||||
/// <param name="suspendLoad">场景加载到90%自动挂起</param>
|
/// <param name="suspendLoad">场景加载到90%自动挂起</param>
|
||||||
/// <param name="priority">加载的优先级</param>
|
/// <param name="priority">加载的优先级</param>
|
||||||
public SceneHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool suspendLoad = false, uint priority = 0)
|
public SceneHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, LocalPhysicsMode physicsMode = LocalPhysicsMode.None, bool suspendLoad = false, uint priority = 0)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
return LoadSceneInternal(assetInfo, false, sceneMode, suspendLoad, priority);
|
return LoadSceneInternal(assetInfo, false, sceneMode, physicsMode, suspendLoad, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SceneHandle LoadSceneInternal(AssetInfo assetInfo, bool waitForAsyncComplete, LoadSceneMode sceneMode, bool suspendLoad, uint priority)
|
private SceneHandle LoadSceneInternal(AssetInfo assetInfo, bool waitForAsyncComplete, LoadSceneMode sceneMode, LocalPhysicsMode physicsMode, bool suspendLoad, uint priority)
|
||||||
{
|
{
|
||||||
DebugCheckAssetLoadType(assetInfo.AssetType);
|
DebugCheckAssetLoadType(assetInfo.AssetType);
|
||||||
var handle = _resourceManager.LoadSceneAsync(assetInfo, sceneMode, suspendLoad, priority);
|
var loadSceneParams = new LoadSceneParameters(sceneMode, physicsMode);
|
||||||
|
var handle = _resourceManager.LoadSceneAsync(assetInfo, loadSceneParams, suspendLoad, priority);
|
||||||
if (waitForAsyncComplete)
|
if (waitForAsyncComplete)
|
||||||
handle.WaitForAsyncComplete();
|
handle.WaitForAsyncComplete();
|
||||||
return handle;
|
return handle;
|
||||||
|
|||||||
@@ -34,5 +34,15 @@ namespace YooAsset
|
|||||||
/// 注意:加载流对象在资源包对象释放的时候会自动释放
|
/// 注意:加载流对象在资源包对象释放的时候会自动释放
|
||||||
/// </summary>
|
/// </summary>
|
||||||
AssetBundleCreateRequest LoadAssetBundleAsync(DecryptFileInfo fileInfo, out Stream managedStream);
|
AssetBundleCreateRequest LoadAssetBundleAsync(DecryptFileInfo fileInfo, out Stream managedStream);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取解密的字节数据
|
||||||
|
/// </summary>
|
||||||
|
byte[] ReadFileData(DecryptFileInfo fileInfo);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取解密的文本数据
|
||||||
|
/// </summary>
|
||||||
|
string ReadFileText(DecryptFileInfo fileInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,10 +161,11 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="location">场景的定位地址</param>
|
/// <param name="location">场景的定位地址</param>
|
||||||
/// <param name="sceneMode">场景加载模式</param>
|
/// <param name="sceneMode">场景加载模式</param>
|
||||||
public static SceneHandle LoadSceneSync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single)
|
/// <param name="physicsMode">场景物理模式</param>
|
||||||
|
public static SceneHandle LoadSceneSync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, LocalPhysicsMode physicsMode = LocalPhysicsMode.None)
|
||||||
{
|
{
|
||||||
DebugCheckDefaultPackageValid();
|
DebugCheckDefaultPackageValid();
|
||||||
return _defaultPackage.LoadSceneSync(location, sceneMode);
|
return _defaultPackage.LoadSceneSync(location, sceneMode, physicsMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -172,10 +173,11 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assetInfo">场景的资源信息</param>
|
/// <param name="assetInfo">场景的资源信息</param>
|
||||||
/// <param name="sceneMode">场景加载模式</param>
|
/// <param name="sceneMode">场景加载模式</param>
|
||||||
public static SceneHandle LoadSceneSync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single)
|
/// <param name="physicsMode">场景物理模式</param>
|
||||||
|
public static SceneHandle LoadSceneSync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, LocalPhysicsMode physicsMode = LocalPhysicsMode.None)
|
||||||
{
|
{
|
||||||
DebugCheckDefaultPackageValid();
|
DebugCheckDefaultPackageValid();
|
||||||
return _defaultPackage.LoadSceneSync(assetInfo, sceneMode);
|
return _defaultPackage.LoadSceneSync(assetInfo, sceneMode, physicsMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -183,12 +185,13 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="location">场景的定位地址</param>
|
/// <param name="location">场景的定位地址</param>
|
||||||
/// <param name="sceneMode">场景加载模式</param>
|
/// <param name="sceneMode">场景加载模式</param>
|
||||||
|
/// <param name="physicsMode">场景物理模式</param>
|
||||||
/// <param name="suspendLoad">场景加载到90%自动挂起</param>
|
/// <param name="suspendLoad">场景加载到90%自动挂起</param>
|
||||||
/// <param name="priority">优先级</param>
|
/// <param name="priority">优先级</param>
|
||||||
public static SceneHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool suspendLoad = false, uint priority = 100)
|
public static SceneHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, LocalPhysicsMode physicsMode = LocalPhysicsMode.None, bool suspendLoad = false, uint priority = 100)
|
||||||
{
|
{
|
||||||
DebugCheckDefaultPackageValid();
|
DebugCheckDefaultPackageValid();
|
||||||
return _defaultPackage.LoadSceneAsync(location, sceneMode, suspendLoad, priority);
|
return _defaultPackage.LoadSceneAsync(location, sceneMode, physicsMode, suspendLoad, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -196,12 +199,13 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assetInfo">场景的资源信息</param>
|
/// <param name="assetInfo">场景的资源信息</param>
|
||||||
/// <param name="sceneMode">场景加载模式</param>
|
/// <param name="sceneMode">场景加载模式</param>
|
||||||
|
/// <param name="physicsMode">场景物理模式</param>
|
||||||
/// <param name="suspendLoad">场景加载到90%自动挂起</param>
|
/// <param name="suspendLoad">场景加载到90%自动挂起</param>
|
||||||
/// <param name="priority">优先级</param>
|
/// <param name="priority">优先级</param>
|
||||||
public static SceneHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool suspendLoad = false, uint priority = 100)
|
public static SceneHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, LocalPhysicsMode physicsMode = LocalPhysicsMode.None, bool suspendLoad = false, uint priority = 100)
|
||||||
{
|
{
|
||||||
DebugCheckDefaultPackageValid();
|
DebugCheckDefaultPackageValid();
|
||||||
return _defaultPackage.LoadSceneAsync(assetInfo, sceneMode, suspendLoad, priority);
|
return _defaultPackage.LoadSceneAsync(assetInfo, sceneMode, physicsMode, suspendLoad, priority);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -172,6 +172,22 @@ internal class FsmInitializePackage : IStateNode
|
|||||||
return AssetBundle.LoadFromStreamAsync(bundleStream, fileInfo.FileLoadCRC, GetManagedReadBufferSize());
|
return AssetBundle.LoadFromStreamAsync(bundleStream, fileInfo.FileLoadCRC, GetManagedReadBufferSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取解密的字节数据
|
||||||
|
/// </summary>
|
||||||
|
byte[] IDecryptionServices.ReadFileData(DecryptFileInfo fileInfo)
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取解密的文本数据
|
||||||
|
/// </summary>
|
||||||
|
string IDecryptionServices.ReadFileText(DecryptFileInfo fileInfo)
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
private static uint GetManagedReadBufferSize()
|
private static uint GetManagedReadBufferSize()
|
||||||
{
|
{
|
||||||
return 1024;
|
return 1024;
|
||||||
@@ -203,6 +219,22 @@ internal class FsmInitializePackage : IStateNode
|
|||||||
return AssetBundle.LoadFromFileAsync(fileInfo.FileLoadPath, fileInfo.FileLoadCRC, GetFileOffset());
|
return AssetBundle.LoadFromFileAsync(fileInfo.FileLoadPath, fileInfo.FileLoadCRC, GetFileOffset());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取解密的字节数据
|
||||||
|
/// </summary>
|
||||||
|
byte[] IDecryptionServices.ReadFileData(DecryptFileInfo fileInfo)
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取解密的文本数据
|
||||||
|
/// </summary>
|
||||||
|
string IDecryptionServices.ReadFileText(DecryptFileInfo fileInfo)
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
private static ulong GetFileOffset()
|
private static ulong GetFileOffset()
|
||||||
{
|
{
|
||||||
return 32;
|
return 32;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "com.tuyoogame.yooasset",
|
"name": "com.tuyoogame.yooasset",
|
||||||
"displayName": "YooAsset",
|
"displayName": "YooAsset",
|
||||||
"version": "2.2.2-preview",
|
"version": "2.2.3-preview",
|
||||||
"unity": "2019.4",
|
"unity": "2019.4",
|
||||||
"description": "unity3d resources management system.",
|
"description": "unity3d resources management system.",
|
||||||
"author": {
|
"author": {
|
||||||
|
|||||||
Reference in New Issue
Block a user