mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-14 19:40:47 +00:00
Compare commits
55 Commits
1.3.0-prev
...
1.3.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
92e7ec9682 | ||
|
|
32b7ff1b36 | ||
|
|
5a68ef558f | ||
|
|
18d48ae963 | ||
|
|
d61c723933 | ||
|
|
bb64ff7278 | ||
|
|
d7760cd34d | ||
|
|
f9ecad1cf0 | ||
|
|
a6de89ab74 | ||
|
|
e663dcf83b | ||
|
|
88e8e5cd54 | ||
|
|
9b43d36793 | ||
|
|
794314a8e1 | ||
|
|
0a1c40cee5 | ||
|
|
958cdd25a5 | ||
|
|
2fb77c1bf8 | ||
|
|
3aa46664f7 | ||
|
|
8389ce5793 | ||
|
|
5199430766 | ||
|
|
0afe5ada2c | ||
|
|
1774eb63b7 | ||
|
|
609cd21603 | ||
|
|
97fc65e66d | ||
|
|
ccac691701 | ||
|
|
a283c8bbad | ||
|
|
9bc5580229 | ||
|
|
eca5d73b94 | ||
|
|
fdacd5f3f8 | ||
|
|
c449a070b4 | ||
|
|
9e2efe3717 | ||
|
|
90ad292b84 | ||
|
|
f2422ed16c | ||
|
|
52ac982481 | ||
|
|
661c3a6d61 | ||
|
|
c14db5fd0d | ||
|
|
6116e49a05 | ||
|
|
8b6cd759ef | ||
|
|
e3f1ad79a8 | ||
|
|
b4c190efb7 | ||
|
|
bd11f2e7b8 | ||
|
|
1f26f001e9 | ||
|
|
ecd2bb4590 | ||
|
|
330eabcfc5 | ||
|
|
bd8ecab31b | ||
|
|
e9af0c7042 | ||
|
|
72a49d0ed8 | ||
|
|
66304c91ec | ||
|
|
c2192dd657 | ||
|
|
1de9e0b79d | ||
|
|
608f401a80 | ||
|
|
ef1acdc3d1 | ||
|
|
82631fb336 | ||
|
|
a348d9131d | ||
|
|
fc575f5bc0 | ||
|
|
e277649878 |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -58,7 +58,4 @@ sysinfo.txt
|
||||
# Crashlytics generated file
|
||||
crashlytics-build.properties
|
||||
|
||||
*.vsconfig
|
||||
|
||||
Sandbox/
|
||||
Bundles/
|
||||
*.vsconfig
|
||||
@@ -2,6 +2,146 @@
|
||||
|
||||
All notable changes to this package will be documented in this file.
|
||||
|
||||
## [1.3.2] - 2022-10-22
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复了AssetBundleCollector界面点击修复按钮界面没有刷新的问题。
|
||||
|
||||
### Added
|
||||
|
||||
- 新增了自定义证书认证方法。
|
||||
|
||||
````c#
|
||||
public static class YooAssets
|
||||
{
|
||||
/// <summary>
|
||||
/// 设置下载系统参数,自定义的证书认证实例
|
||||
/// </summary>
|
||||
public static void SetDownloadSystemCertificateHandler(UnityEngine.Networking.CertificateHandler instance)
|
||||
}
|
||||
````
|
||||
|
||||
- 新增了下载失败后清理文件的方法。
|
||||
|
||||
````c#
|
||||
public static class YooAssets
|
||||
{
|
||||
/// <summary>
|
||||
/// 设置下载系统参数,下载失败后清理文件的HTTP错误码
|
||||
/// </summary>
|
||||
public static void SetDownloadSystemClearFileResponseCode(List<long> codes)
|
||||
}
|
||||
````
|
||||
|
||||
- 新增了检查资源定位地址是否有效的方法。
|
||||
|
||||
```c#
|
||||
public class AssetsPackage
|
||||
{
|
||||
/// <summary>
|
||||
/// 检查资源定位地址是否有效
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public bool CheckLocationValid(string location)
|
||||
}
|
||||
```
|
||||
|
||||
### Removed
|
||||
|
||||
- 移除了ILocationServices接口类和初始化字段。
|
||||
- 移除了AssetPackage.GetAssetPath(string location)方法。
|
||||
- 移除了BuildParameters.EnableAddressable字段。
|
||||
|
||||
### Changed
|
||||
|
||||
- AssetBundleCollector配置增加了UniqueBundleName设置,用于解决不同包裹之间Bundle名称冲突的问题。
|
||||
|
||||
## [1.3.1] - 2022-10-18
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复了原生文件每次获取都重复拷贝的问题。
|
||||
- 修复了断点续传下载字节数统计不准确的问题。
|
||||
|
||||
### Added
|
||||
|
||||
- 所有下载相关方法增加超时判断参数。
|
||||
|
||||
- 新增首包资源文件拷贝选项。
|
||||
|
||||
```c#
|
||||
public class BuildParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 拷贝内置资源选项
|
||||
/// </summary>
|
||||
public ECopyBuildinFileOption CopyBuildinFileOption = ECopyBuildinFileOption.None;
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝内置资源的标签
|
||||
/// </summary>
|
||||
public string CopyBuildinFileTags = string.Empty;
|
||||
}
|
||||
```
|
||||
|
||||
- 新增资源包初始化查询字段。
|
||||
|
||||
```c#
|
||||
public class AssetsPackage
|
||||
{
|
||||
/// <summary>
|
||||
/// 初始化状态
|
||||
/// </summary>
|
||||
public EOperationStatus InitializeStatus
|
||||
}
|
||||
```
|
||||
|
||||
- 增加获取人类可读的版本信息。
|
||||
|
||||
````c#
|
||||
public class AssetsPackage
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取人类可读的版本信息
|
||||
/// </summary>
|
||||
public string GetHumanReadableVersion()
|
||||
}
|
||||
````
|
||||
|
||||
- 新增资源缓存清理方法。
|
||||
|
||||
```c#
|
||||
public static class YooAssets
|
||||
{
|
||||
/// <summary>
|
||||
/// 清理未使用的缓存文件
|
||||
/// </summary>
|
||||
public static ClearUnusedCacheFilesOperation ClearUnusedCacheFiles()
|
||||
}
|
||||
```
|
||||
|
||||
- 异步操作类新增繁忙查询方法。
|
||||
|
||||
````c#
|
||||
public abstract class GameAsyncOperation
|
||||
{
|
||||
/// <summary>
|
||||
/// 异步操作系统是否繁忙
|
||||
/// </summary>
|
||||
protected bool IsBusy()
|
||||
}
|
||||
````
|
||||
|
||||
### Removed
|
||||
|
||||
- 移除了AssetsPackage.IsInitialized()方法。
|
||||
- 移除了YooAssets.ClearAllCacheFiles()方法。
|
||||
|
||||
### Changed
|
||||
|
||||
- YooAssetsPackage类重名为AssetsPackage
|
||||
|
||||
## [1.3.0-preview] - 2022-10-08
|
||||
|
||||
该预览版本提供了分布式构建的功能,用于解决分工程或分内容构建的问题。
|
||||
|
||||
@@ -59,6 +59,7 @@ namespace YooAsset.Editor
|
||||
new TaskCreatePatchManifest(), //创建清单文件
|
||||
new TaskCreateReport(), //创建报告文件
|
||||
new TaskCreatePatchPackage(), //制作补丁包
|
||||
new TaskCopyBuildinFiles(), //拷贝内置文件
|
||||
};
|
||||
}
|
||||
else if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||
@@ -73,6 +74,7 @@ namespace YooAsset.Editor
|
||||
new TaskCreatePatchManifest(), //创建清单文件
|
||||
new TaskCreateReport(), //创建报告文件
|
||||
new TaskCreatePatchPackage(), //制作补丁包
|
||||
new TaskCopyBuildinFiles(), //拷贝内置文件
|
||||
};
|
||||
}
|
||||
else
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public static string GetStreamingAssetsFolderPath()
|
||||
{
|
||||
return $"{Application.dataPath}/StreamingAssets/YooAssets/";
|
||||
return $"{Application.dataPath}/StreamingAssets/{YooAssetSettings.StreamingAssetsBuildinFolder}/";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -30,6 +30,16 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public EOutputNameStyle OutputNameStyle = EOutputNameStyle.HashName;
|
||||
|
||||
/// <summary>
|
||||
/// 首包资源文件的拷贝方式
|
||||
/// </summary>
|
||||
public ECopyBuildinFileOption CopyBuildinFileOption = ECopyBuildinFileOption.None;
|
||||
|
||||
/// <summary>
|
||||
/// 首包资源文件的标签集合
|
||||
/// </summary>
|
||||
public string CopyBuildinFileTags = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 加密类名称
|
||||
/// </summary>
|
||||
|
||||
@@ -31,6 +31,8 @@ namespace YooAsset.Editor
|
||||
private PopupField<string> _encryptionField;
|
||||
private EnumField _compressionField;
|
||||
private EnumField _outputNameStyleField;
|
||||
private EnumField _copyBuildinFileOptionField;
|
||||
private TextField _copyBuildinFileTagsField;
|
||||
|
||||
public void CreateGUI()
|
||||
{
|
||||
@@ -135,7 +137,7 @@ namespace YooAsset.Editor
|
||||
encryptionContainer.Add(_encryptionField);
|
||||
}
|
||||
|
||||
// 压缩方式
|
||||
// 压缩方式选项
|
||||
_compressionField = root.Q<EnumField>("Compression");
|
||||
_compressionField.Init(AssetBundleBuilderSettingData.Setting.CompressOption);
|
||||
_compressionField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.CompressOption);
|
||||
@@ -157,6 +159,27 @@ namespace YooAsset.Editor
|
||||
AssetBundleBuilderSettingData.Setting.OutputNameStyle = (EOutputNameStyle)_outputNameStyleField.value;
|
||||
});
|
||||
|
||||
// 首包文件拷贝选项
|
||||
_copyBuildinFileOptionField = root.Q<EnumField>("CopyBuildinFileOption");
|
||||
_copyBuildinFileOptionField.Init(AssetBundleBuilderSettingData.Setting.CopyBuildinFileOption);
|
||||
_copyBuildinFileOptionField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.CopyBuildinFileOption);
|
||||
_copyBuildinFileOptionField.style.width = 350;
|
||||
_copyBuildinFileOptionField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSettingData.IsDirty = true;
|
||||
AssetBundleBuilderSettingData.Setting.CopyBuildinFileOption = (ECopyBuildinFileOption)_copyBuildinFileOptionField.value;
|
||||
RefreshWindow();
|
||||
});
|
||||
|
||||
// 首包文件的资源标签
|
||||
_copyBuildinFileTagsField = root.Q<TextField>("CopyBuildinFileTags");
|
||||
_copyBuildinFileTagsField.SetValueWithoutNotify(AssetBundleBuilderSettingData.Setting.CopyBuildinFileTags);
|
||||
_copyBuildinFileTagsField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSettingData.IsDirty = true;
|
||||
AssetBundleBuilderSettingData.Setting.CopyBuildinFileTags = _copyBuildinFileTagsField.value;
|
||||
});
|
||||
|
||||
// 构建按钮
|
||||
var buildButton = root.Q<Button>("Build");
|
||||
buildButton.clicked += BuildButton_clicked; ;
|
||||
@@ -193,10 +216,15 @@ namespace YooAsset.Editor
|
||||
private void RefreshWindow()
|
||||
{
|
||||
var buildMode = AssetBundleBuilderSettingData.Setting.BuildMode;
|
||||
var copyOption = AssetBundleBuilderSettingData.Setting.CopyBuildinFileOption;
|
||||
bool enableElement = buildMode == EBuildMode.ForceRebuild;
|
||||
bool tagsFiledVisible = copyOption == ECopyBuildinFileOption.ClearAndCopyByTags || copyOption == ECopyBuildinFileOption.OnlyCopyByTags;
|
||||
_encryptionField.SetEnabled(enableElement);
|
||||
_compressionField.SetEnabled(enableElement);
|
||||
_outputNameStyleField.SetEnabled(enableElement);
|
||||
_copyBuildinFileOptionField.SetEnabled(enableElement);
|
||||
_copyBuildinFileTagsField.SetEnabled(enableElement);
|
||||
_copyBuildinFileTagsField.visible = tagsFiledVisible;
|
||||
}
|
||||
private void SaveBtn_clicked()
|
||||
{
|
||||
@@ -229,10 +257,11 @@ namespace YooAsset.Editor
|
||||
buildParameters.BuildMode = AssetBundleBuilderSettingData.Setting.BuildMode;
|
||||
buildParameters.BuildPackage = AssetBundleBuilderSettingData.Setting.BuildPackage;
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
|
||||
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
|
||||
buildParameters.CompressOption = AssetBundleBuilderSettingData.Setting.CompressOption;
|
||||
buildParameters.OutputNameStyle = AssetBundleBuilderSettingData.Setting.OutputNameStyle;
|
||||
buildParameters.CopyBuildinFileOption = AssetBundleBuilderSettingData.Setting.CopyBuildinFileOption;
|
||||
buildParameters.CopyBuildinFileTags = AssetBundleBuilderSettingData.Setting.CopyBuildinFileTags;
|
||||
|
||||
if (AssetBundleBuilderSettingData.Setting.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||
{
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
<ui:VisualElement name="EncryptionContainer" style="height: 24px;" />
|
||||
<uie:EnumField label="Compression" value="Center" name="Compression" />
|
||||
<uie:EnumField label="Output Name Style" value="Center" name="OutputNameStyle" />
|
||||
<uie:EnumField label="Copy Buildin File Option" value="Center" name="CopyBuildinFileOption" />
|
||||
<ui:TextField picking-mode="Ignore" label="Copy Buildin File Tags" name="CopyBuildinFileTags" />
|
||||
<ui:Button text="构建" display-tooltip-when-elided="true" name="Build" style="height: 50px; background-color: rgb(40, 106, 42); margin-top: 10px;" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 模拟构建
|
||||
/// </summary>
|
||||
public static string SimulateBuild(string packageName, bool enableAddressable)
|
||||
public static string SimulateBuild(string packageName)
|
||||
{
|
||||
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot();
|
||||
BuildParameters buildParameters = new BuildParameters();
|
||||
@@ -15,7 +15,6 @@ namespace YooAsset.Editor
|
||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
||||
buildParameters.BuildPackage = packageName;
|
||||
buildParameters.EnableAddressable = enableAddressable;
|
||||
|
||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||
var buildResult = builder.Run(buildParameters);
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace YooAsset.Editor
|
||||
IsRawAsset = isRawAsset;
|
||||
|
||||
System.Type assetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||
if (assetType == typeof(UnityEngine.Shader))
|
||||
if (assetType == typeof(UnityEngine.Shader) || assetType == typeof(UnityEngine.ShaderVariantCollection))
|
||||
IsShaderAsset = true;
|
||||
else
|
||||
IsShaderAsset = false;
|
||||
@@ -76,7 +76,7 @@ namespace YooAsset.Editor
|
||||
IsRawAsset = false;
|
||||
|
||||
System.Type assetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||
if (assetType == typeof(UnityEngine.Shader))
|
||||
if (assetType == typeof(UnityEngine.Shader) || assetType == typeof(UnityEngine.ShaderVariantCollection))
|
||||
IsShaderAsset = true;
|
||||
else
|
||||
IsShaderAsset = false;
|
||||
@@ -166,7 +166,7 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 计算主资源或共享资源的完整包名
|
||||
/// </summary>
|
||||
public void CalculateFullBundleName()
|
||||
public void CalculateFullBundleName(bool uniqueBundleName, string packageName)
|
||||
{
|
||||
if (CollectorType == ECollectorType.None)
|
||||
{
|
||||
@@ -177,15 +177,22 @@ namespace YooAsset.Editor
|
||||
{
|
||||
string shareBundleName = YooAssetSettingsData.GetUnityShadersBundleFullName();
|
||||
_shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_referenceBundleNames.Count > 1)
|
||||
{
|
||||
IPackRule packRule = PackDirectory.StaticPackRule;
|
||||
var bundleName = packRule.GetBundleName(new PackRuleData(AssetPath));
|
||||
var shareBundleName = $"share_{bundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
|
||||
_shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower();
|
||||
}
|
||||
}
|
||||
|
||||
if (_referenceBundleNames.Count > 1)
|
||||
if (uniqueBundleName)
|
||||
{
|
||||
IPackRule packRule = PackDirectory.StaticPackRule;
|
||||
var bundleName = packRule.GetBundleName(new PackRuleData(AssetPath));
|
||||
var shareBundleName = $"share_{bundleName}.{YooAssetSettingsData.Setting.AssetBundleFileVariant}";
|
||||
_shareBundleName = EditorTools.GetRegularPath(shareBundleName).ToLower();
|
||||
if (string.IsNullOrEmpty(_shareBundleName) == false)
|
||||
_shareBundleName = $"{packageName.ToLower()}_{_shareBundleName}";
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -89,14 +89,6 @@ namespace YooAsset.Editor
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取文件的扩展名
|
||||
/// </summary>
|
||||
public string GetAppendExtension()
|
||||
{
|
||||
return System.IO.Path.GetExtension(BundleName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建的资源路径列表
|
||||
/// </summary>
|
||||
|
||||
@@ -14,6 +14,16 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public int AssetFileCount;
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用可寻址资源定位
|
||||
/// </summary>
|
||||
public bool EnableAddressable;
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名唯一化
|
||||
/// </summary>
|
||||
public bool UniqueBundleName;
|
||||
|
||||
/// <summary>
|
||||
/// 资源包列表
|
||||
/// </summary>
|
||||
|
||||
@@ -19,7 +19,8 @@ namespace YooAsset.Editor
|
||||
AssetBundleCollectorSettingData.Setting.CheckConfigError();
|
||||
|
||||
// 2. 获取所有收集器收集的资源
|
||||
List<CollectAssetInfo> allCollectAssets = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
|
||||
var buildResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
|
||||
List<CollectAssetInfo> allCollectAssets = buildResult.CollectAssets;
|
||||
|
||||
// 3. 剔除未被引用的依赖资源
|
||||
List<CollectAssetInfo> removeDependList = new List<CollectAssetInfo>();
|
||||
@@ -72,9 +73,13 @@ namespace YooAsset.Editor
|
||||
}
|
||||
}
|
||||
}
|
||||
context.AssetFileCount = buildAssetDic.Count;
|
||||
|
||||
// 6. 填充主动收集资源的依赖列表
|
||||
// 6. 记录关键信息
|
||||
context.AssetFileCount = buildAssetDic.Count;
|
||||
context.EnableAddressable = buildResult.EnableAddressable;
|
||||
context.UniqueBundleName = buildResult.UniqueBundleName;
|
||||
|
||||
// 7. 填充主动收集资源的依赖列表
|
||||
foreach (var collectAssetInfo in allCollectAssets)
|
||||
{
|
||||
var dependAssetInfos = new List<BuildAssetInfo>(collectAssetInfo.DependAssets.Count);
|
||||
@@ -88,13 +93,13 @@ namespace YooAsset.Editor
|
||||
buildAssetDic[collectAssetInfo.AssetPath].SetAllDependAssetInfos(dependAssetInfos);
|
||||
}
|
||||
|
||||
// 7. 计算完整的资源包名
|
||||
// 8. 计算完整的资源包名
|
||||
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
|
||||
{
|
||||
pair.Value.CalculateFullBundleName();
|
||||
pair.Value.CalculateFullBundleName(buildResult.UniqueBundleName, buildResult.PackageName);
|
||||
}
|
||||
|
||||
// 8. 移除不参与构建的资源
|
||||
// 9. 移除不参与构建的资源
|
||||
List<BuildAssetInfo> removeBuildList = new List<BuildAssetInfo>();
|
||||
foreach (KeyValuePair<string, BuildAssetInfo> pair in buildAssetDic)
|
||||
{
|
||||
@@ -107,7 +112,7 @@ namespace YooAsset.Editor
|
||||
buildAssetDic.Remove(removeValue.AssetPath);
|
||||
}
|
||||
|
||||
// 9. 构建资源包
|
||||
// 10. 构建资源包
|
||||
var allBuildinAssets = buildAssetDic.Values.ToList();
|
||||
if (allBuildinAssets.Count == 0)
|
||||
throw new Exception("构建的资源列表不能为空");
|
||||
|
||||
@@ -61,17 +61,17 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public string BuildPackage;
|
||||
|
||||
/// <summary>
|
||||
/// 人类可读的版本信息
|
||||
/// </summary>
|
||||
public string HumanReadableVersion;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 验证构建结果
|
||||
/// </summary>
|
||||
public bool VerifyBuildingResult = false;
|
||||
|
||||
/// <summary>
|
||||
/// 启用可寻址资源定位
|
||||
/// </summary>
|
||||
public bool EnableAddressable = false;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 加密类
|
||||
/// </summary>
|
||||
@@ -82,6 +82,16 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public EOutputNameStyle OutputNameStyle = EOutputNameStyle.HashName;
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝内置资源选项
|
||||
/// </summary>
|
||||
public ECopyBuildinFileOption CopyBuildinFileOption = ECopyBuildinFileOption.None;
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝内置资源的标签
|
||||
/// </summary>
|
||||
public string CopyBuildinFileTags = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 压缩选项
|
||||
/// </summary>
|
||||
|
||||
@@ -53,6 +53,11 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public bool EnableAddressable;
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名唯一化
|
||||
/// </summary>
|
||||
public bool UniqueBundleName;
|
||||
|
||||
/// <summary>
|
||||
/// 加密服务类名称
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[TaskAttribute("拷贝内置文件到流目录")]
|
||||
public class TaskCopyBuildinFiles : IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
if (buildParametersContext.Parameters.CopyBuildinFileOption != ECopyBuildinFileOption.None)
|
||||
{
|
||||
CopyBuildinFilesToStreaming(buildParametersContext);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝首包资源文件
|
||||
/// </summary>
|
||||
private void CopyBuildinFilesToStreaming(BuildParametersContext buildParametersContext)
|
||||
{
|
||||
ECopyBuildinFileOption option = buildParametersContext.Parameters.CopyBuildinFileOption;
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
string streamingAssetsDirectory = AssetBundleBuilderHelper.GetStreamingAssetsFolderPath();
|
||||
string buildPackageName = buildParametersContext.Parameters.BuildPackage;
|
||||
string outputPackageCRC = buildParametersContext.OutputPackageCRC;
|
||||
|
||||
// 加载补丁清单
|
||||
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(packageOutputDirectory, buildPackageName, outputPackageCRC);
|
||||
|
||||
// 清空流目录
|
||||
if (option == ECopyBuildinFileOption.ClearAndCopyAll || option == ECopyBuildinFileOption.ClearAndCopyByTags)
|
||||
{
|
||||
AssetBundleBuilderHelper.ClearStreamingAssetsFolder();
|
||||
}
|
||||
|
||||
// 拷贝补丁清单文件
|
||||
{
|
||||
string manifestFileName = YooAssetSettingsData.GetPatchManifestFileName(buildPackageName, outputPackageCRC);
|
||||
string sourcePath = $"{packageOutputDirectory}/{manifestFileName}";
|
||||
string destPath = $"{streamingAssetsDirectory}/{manifestFileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝静态版本文件
|
||||
{
|
||||
string versionFileName = YooAssetSettingsData.GetStaticVersionFileName(buildPackageName);
|
||||
string sourcePath = $"{packageOutputDirectory}/{versionFileName}";
|
||||
string destPath = $"{streamingAssetsDirectory}/{versionFileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝文件列表(所有文件)
|
||||
if (option == ECopyBuildinFileOption.ClearAndCopyAll || option == ECopyBuildinFileOption.OnlyCopyAll)
|
||||
{
|
||||
foreach (var patchBundle in patchManifest.BundleList)
|
||||
{
|
||||
string sourcePath = $"{packageOutputDirectory}/{patchBundle.FileName}";
|
||||
string destPath = $"{streamingAssetsDirectory}/{patchBundle.FileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
}
|
||||
|
||||
// 拷贝文件列表(带标签的文件)
|
||||
if (option == ECopyBuildinFileOption.ClearAndCopyByTags || option == ECopyBuildinFileOption.OnlyCopyByTags)
|
||||
{
|
||||
string[] tags = buildParametersContext.Parameters.CopyBuildinFileTags.Split(';');
|
||||
foreach (var patchBundle in patchManifest.BundleList)
|
||||
{
|
||||
if (patchBundle.HasTag(tags) == false)
|
||||
continue;
|
||||
string sourcePath = $"{packageOutputDirectory}/{patchBundle.FileName}";
|
||||
string destPath = $"{streamingAssetsDirectory}/{patchBundle.FileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
}
|
||||
|
||||
// 刷新目录
|
||||
AssetDatabase.Refresh();
|
||||
BuildRunner.Log($"内置文件拷贝完成:{streamingAssetsDirectory}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cfc81e18e5b5f6f4b821c7427b34d349
|
||||
guid: 5c77e17c3a3a57548a218f1cd26f5a55
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -21,6 +21,7 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
private void CreatePatchManifestFile(BuildContext context)
|
||||
{
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = buildParametersContext.Parameters;
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
@@ -28,9 +29,10 @@ namespace YooAsset.Editor
|
||||
// 创建新补丁清单
|
||||
PatchManifest patchManifest = new PatchManifest();
|
||||
patchManifest.FileVersion = YooAssetSettings.PatchManifestFileVersion;
|
||||
patchManifest.EnableAddressable = buildParameters.EnableAddressable;
|
||||
patchManifest.EnableAddressable = buildMapContext.EnableAddressable;
|
||||
patchManifest.OutputNameStyle = (int)buildParameters.OutputNameStyle;
|
||||
patchManifest.PackageName = buildParameters.BuildPackage;
|
||||
patchManifest.HumanReadableVersion = buildParameters.HumanReadableVersion;
|
||||
patchManifest.BundleList = GetAllPatchBundle(context);
|
||||
patchManifest.AssetList = GetAllPatchAsset(context, patchManifest);
|
||||
|
||||
@@ -124,7 +126,6 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
private List<PatchAsset> GetAllPatchAsset(BuildContext context, PatchManifest patchManifest)
|
||||
{
|
||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
|
||||
List<PatchAsset> result = new List<PatchAsset>(1000);
|
||||
@@ -134,7 +135,7 @@ namespace YooAsset.Editor
|
||||
foreach (var assetInfo in assetInfos)
|
||||
{
|
||||
PatchAsset patchAsset = new PatchAsset();
|
||||
if (buildParameters.Parameters.EnableAddressable)
|
||||
if (buildMapContext.EnableAddressable)
|
||||
patchAsset.Address = assetInfo.Address;
|
||||
else
|
||||
patchAsset.Address = string.Empty;
|
||||
|
||||
@@ -46,7 +46,9 @@ namespace YooAsset.Editor
|
||||
buildReport.Summary.BuildPipeline = buildParameters.BuildPipeline;
|
||||
buildReport.Summary.BuildMode = buildParameters.BuildMode;
|
||||
buildReport.Summary.BuildPackage = buildParameters.BuildPackage;
|
||||
buildReport.Summary.EnableAddressable = buildParameters.EnableAddressable;
|
||||
buildReport.Summary.EnableAddressable = buildMapContext.EnableAddressable;
|
||||
buildReport.Summary.UniqueBundleName = buildMapContext.UniqueBundleName;
|
||||
|
||||
buildReport.Summary.EncryptionServicesClassName = buildParameters.EncryptionServices == null ?
|
||||
"null" : buildParameters.EncryptionServices.GetType().FullName;
|
||||
|
||||
|
||||
@@ -32,9 +32,18 @@ namespace YooAsset.Editor
|
||||
if (EditorTools.HasDirtyScenes())
|
||||
throw new Exception("检测到未保存的场景文件");
|
||||
|
||||
// 检测首包资源标签
|
||||
if (buildParameters.CopyBuildinFileOption == ECopyBuildinFileOption.ClearAndCopyByTags
|
||||
|| buildParameters.CopyBuildinFileOption == ECopyBuildinFileOption.OnlyCopyByTags)
|
||||
{
|
||||
if (string.IsNullOrEmpty(buildParameters.CopyBuildinFileTags))
|
||||
throw new Exception("首包资源标签不能为空!");
|
||||
}
|
||||
|
||||
// 保存改动的资源
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
|
||||
if (buildParameters.BuildMode == EBuildMode.ForceRebuild)
|
||||
{
|
||||
// 删除平台总目录
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 首包资源文件的拷贝方式
|
||||
/// </summary>
|
||||
public enum ECopyBuildinFileOption
|
||||
{
|
||||
/// <summary>
|
||||
/// 不拷贝任何文件
|
||||
/// </summary>
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 先清空已有文件,然后拷贝所有文件
|
||||
/// </summary>
|
||||
ClearAndCopyAll,
|
||||
|
||||
/// <summary>
|
||||
/// 先清空已有文件,然后按照资源标签拷贝文件
|
||||
/// </summary>
|
||||
ClearAndCopyByTags,
|
||||
|
||||
/// <summary>
|
||||
/// 不清空已有文件,直接拷贝所有文件
|
||||
/// </summary>
|
||||
OnlyCopyAll,
|
||||
|
||||
/// <summary>
|
||||
/// 不清空已有文件,直接按照资源标签拷贝文件
|
||||
/// </summary>
|
||||
OnlyCopyByTags,
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d996937ba73c9b4bb942b8ba6f43398
|
||||
guid: 4defd475b635cdf4b87108140d3a0ad1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -132,10 +132,10 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 获取打包收集的资源文件
|
||||
/// </summary>
|
||||
public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode, bool enableAddressable, AssetBundleCollectorGroup group)
|
||||
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command, AssetBundleCollectorGroup group)
|
||||
{
|
||||
// 注意:模拟构建模式下只收集主资源
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
if (command.BuildMode == EBuildMode.SimulateBuild)
|
||||
{
|
||||
if (CollectorType != ECollectorType.MainAssetCollector)
|
||||
return new List<CollectAssetInfo>();
|
||||
@@ -162,7 +162,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
if (result.ContainsKey(assetPath) == false)
|
||||
{
|
||||
var collectAssetInfo = CreateCollectAssetInfo(buildMode, group, assetPath, isRawAsset);
|
||||
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath, isRawAsset);
|
||||
result.Add(assetPath, collectAssetInfo);
|
||||
}
|
||||
else
|
||||
@@ -177,7 +177,7 @@ namespace YooAsset.Editor
|
||||
string assetPath = CollectPath;
|
||||
if (IsValidateAsset(assetPath) && IsCollectAsset(assetPath))
|
||||
{
|
||||
var collectAssetInfo = CreateCollectAssetInfo(buildMode, group, assetPath, isRawAsset);
|
||||
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath, isRawAsset);
|
||||
result.Add(assetPath, collectAssetInfo);
|
||||
}
|
||||
else
|
||||
@@ -187,7 +187,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
// 检测可寻址地址是否重复
|
||||
if (enableAddressable)
|
||||
if (command.EnableAddressable)
|
||||
{
|
||||
HashSet<string> adressTemper = new HashSet<string>();
|
||||
foreach (var collectInfoPair in result)
|
||||
@@ -207,7 +207,7 @@ namespace YooAsset.Editor
|
||||
return result.Values.ToList();
|
||||
}
|
||||
|
||||
private CollectAssetInfo CreateCollectAssetInfo(EBuildMode buildMode, AssetBundleCollectorGroup group, string assetPath, bool isRawAsset)
|
||||
private CollectAssetInfo CreateCollectAssetInfo(CollectCommand command, AssetBundleCollectorGroup group, string assetPath, bool isRawAsset)
|
||||
{
|
||||
string address = GetAddress(group, assetPath);
|
||||
string bundleName = GetBundleName(group, assetPath);
|
||||
@@ -215,7 +215,7 @@ namespace YooAsset.Editor
|
||||
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, assetTags, isRawAsset);
|
||||
|
||||
// 注意:模拟构建模式下不需要收集依赖资源
|
||||
if (buildMode == EBuildMode.SimulateBuild)
|
||||
if (command.BuildMode == EBuildMode.SimulateBuild)
|
||||
collectAssetInfo.DependAssets = new List<string>();
|
||||
else
|
||||
collectAssetInfo.DependAssets = GetAllDependencies(assetPath);
|
||||
@@ -266,7 +266,7 @@ namespace YooAsset.Editor
|
||||
private bool IsCollectAsset(string assetPath)
|
||||
{
|
||||
Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||
if (assetType == typeof(UnityEngine.Shader))
|
||||
if (assetType == typeof(UnityEngine.Shader) || assetType == typeof(UnityEngine.ShaderVariantCollection))
|
||||
return true;
|
||||
|
||||
// 根据规则设置过滤资源文件
|
||||
@@ -285,10 +285,8 @@ namespace YooAsset.Editor
|
||||
private string GetBundleName(AssetBundleCollectorGroup group, string assetPath)
|
||||
{
|
||||
System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||
if (assetType == typeof(UnityEngine.Shader))
|
||||
{
|
||||
if (assetType == typeof(UnityEngine.Shader) || assetType == typeof(UnityEngine.ShaderVariantCollection))
|
||||
return EditorTools.GetRegularPath(YooAssetSettings.UnityShadersBundleName).ToLower();
|
||||
}
|
||||
|
||||
// 根据规则设置获取资源包名称
|
||||
IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName);
|
||||
|
||||
@@ -10,11 +10,12 @@ namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetBundleCollectorConfig
|
||||
{
|
||||
public const string ConfigVersion = "2.0";
|
||||
public const string ConfigVersion = "2.1";
|
||||
|
||||
public const string XmlVersion = "Version";
|
||||
public const string XmlCommon = "Common";
|
||||
public const string XmlEnableAddressable = "AutoAddressable";
|
||||
public const string XmlUniqueBundleName = "UniqueBundleName";
|
||||
public const string XmlShowPackageView = "ShowPackageView";
|
||||
|
||||
public const string XmlPackage = "Package";
|
||||
@@ -62,6 +63,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// 读取公共配置
|
||||
bool enableAddressable = false;
|
||||
bool uniqueBundleName = false;
|
||||
bool showPackageView = false;
|
||||
var commonNodeList = root.GetElementsByTagName(XmlCommon);
|
||||
if (commonNodeList.Count > 0)
|
||||
@@ -69,10 +71,13 @@ namespace YooAsset.Editor
|
||||
XmlElement commonElement = commonNodeList[0] as XmlElement;
|
||||
if (commonElement.HasAttribute(XmlEnableAddressable) == false)
|
||||
throw new Exception($"Not found attribute {XmlEnableAddressable} in {XmlCommon}");
|
||||
if (commonElement.HasAttribute(XmlUniqueBundleName) == false)
|
||||
throw new Exception($"Not found attribute {XmlUniqueBundleName} in {XmlCommon}");
|
||||
if (commonElement.HasAttribute(XmlShowPackageView) == false)
|
||||
throw new Exception($"Not found attribute {XmlShowPackageView} in {XmlCommon}");
|
||||
|
||||
enableAddressable = commonElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
|
||||
uniqueBundleName = commonElement.GetAttribute(XmlUniqueBundleName) == "True" ? true : false;
|
||||
showPackageView = commonElement.GetAttribute(XmlShowPackageView) == "True" ? true : false;
|
||||
}
|
||||
|
||||
@@ -146,6 +151,7 @@ namespace YooAsset.Editor
|
||||
// 保存配置数据
|
||||
AssetBundleCollectorSettingData.ClearAll();
|
||||
AssetBundleCollectorSettingData.Setting.EnableAddressable = enableAddressable;
|
||||
AssetBundleCollectorSettingData.Setting.UniqueBundleName = uniqueBundleName;
|
||||
AssetBundleCollectorSettingData.Setting.ShowPackageView = showPackageView;
|
||||
AssetBundleCollectorSettingData.Setting.Packages.AddRange(packages);
|
||||
AssetBundleCollectorSettingData.SaveFile();
|
||||
@@ -175,6 +181,7 @@ namespace YooAsset.Editor
|
||||
// 设置公共配置
|
||||
var commonElement = xmlDoc.CreateElement(XmlCommon);
|
||||
commonElement.SetAttribute(XmlEnableAddressable, AssetBundleCollectorSettingData.Setting.EnableAddressable.ToString());
|
||||
commonElement.SetAttribute(XmlUniqueBundleName, AssetBundleCollectorSettingData.Setting.UniqueBundleName.ToString());
|
||||
commonElement.SetAttribute(XmlShowPackageView, AssetBundleCollectorSettingData.Setting.ShowPackageView.ToString());
|
||||
root.AppendChild(commonElement);
|
||||
|
||||
@@ -269,7 +276,23 @@ namespace YooAsset.Editor
|
||||
|
||||
// 更新版本
|
||||
root.SetAttribute(XmlVersion, "2.0");
|
||||
return UpdateXmlConfig(xmlDoc);
|
||||
}
|
||||
|
||||
// 2.0 -> 2.1
|
||||
if (configVersion == "2.0")
|
||||
{
|
||||
// 添加公共元素属性
|
||||
var commonNodeList = root.GetElementsByTagName(XmlCommon);
|
||||
if (commonNodeList.Count > 0)
|
||||
{
|
||||
XmlElement commonElement = commonNodeList[0] as XmlElement;
|
||||
if (commonElement.HasAttribute(XmlUniqueBundleName) == false)
|
||||
commonElement.SetAttribute(XmlUniqueBundleName, "False");
|
||||
}
|
||||
|
||||
// 更新版本
|
||||
root.SetAttribute(XmlVersion, "2.1");
|
||||
return UpdateXmlConfig(xmlDoc);
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 获取打包收集的资源文件
|
||||
/// </summary>
|
||||
public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode, bool enableAddressable)
|
||||
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command)
|
||||
{
|
||||
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace YooAsset.Editor
|
||||
// 收集打包资源
|
||||
foreach (var collector in Collectors)
|
||||
{
|
||||
var temper = collector.GetAllCollectAssets(buildMode, enableAddressable, this);
|
||||
var temper = collector.GetAllCollectAssets(command, this);
|
||||
foreach (var assetInfo in temper)
|
||||
{
|
||||
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
||||
@@ -94,7 +94,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
// 检测可寻址地址是否重复
|
||||
if (enableAddressable)
|
||||
if (command.EnableAddressable)
|
||||
{
|
||||
HashSet<string> adressTemper = new HashSet<string>();
|
||||
foreach (var collectInfoPair in result)
|
||||
|
||||
@@ -56,14 +56,14 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 获取打包收集的资源文件
|
||||
/// </summary>
|
||||
public List<CollectAssetInfo> GetAllCollectAssets(EBuildMode buildMode, bool enableAddressable)
|
||||
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command)
|
||||
{
|
||||
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
||||
|
||||
// 收集打包资源
|
||||
foreach (var group in Groups)
|
||||
{
|
||||
var temper = group.GetAllCollectAssets(buildMode, enableAddressable);
|
||||
var temper = group.GetAllCollectAssets(command);
|
||||
foreach (var assetInfo in temper)
|
||||
{
|
||||
if (result.ContainsKey(assetInfo.AssetPath) == false)
|
||||
@@ -74,7 +74,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
// 检测可寻址地址是否重复
|
||||
if (enableAddressable)
|
||||
if (command.EnableAddressable)
|
||||
{
|
||||
HashSet<string> adressTemper = new HashSet<string>();
|
||||
foreach (var collectInfoPair in result)
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace YooAsset.Editor
|
||||
public class AssetBundleCollectorSetting : ScriptableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否显示包裹视图
|
||||
/// 是否显示包裹列表视图
|
||||
/// </summary>
|
||||
public bool ShowPackageView = false;
|
||||
|
||||
@@ -18,6 +18,11 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public bool EnableAddressable = false;
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名唯一化
|
||||
/// </summary>
|
||||
public bool UniqueBundleName = false;
|
||||
|
||||
/// <summary>
|
||||
/// 包裹列表
|
||||
/// </summary>
|
||||
@@ -76,37 +81,43 @@ namespace YooAsset.Editor
|
||||
Debug.LogWarning($"Not found package : {packageName}");
|
||||
return new List<string>();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取包裹收集的资源文件
|
||||
/// </summary>
|
||||
public List<CollectAssetInfo> GetPackageAssets(EBuildMode buildMode, string packageName)
|
||||
public CollectResult GetPackageAssets(EBuildMode buildMode, string packageName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(packageName))
|
||||
throw new Exception("Build Package name is null or mepty !");
|
||||
throw new Exception("Build package name is null or mepty !");
|
||||
|
||||
foreach (var package in Packages)
|
||||
{
|
||||
if (package.PackageName == packageName)
|
||||
{
|
||||
return package.GetAllCollectAssets(buildMode, EnableAddressable);
|
||||
CollectCommand command = new CollectCommand(buildMode, EnableAddressable);
|
||||
CollectResult collectResult = new CollectResult(package.PackageName, EnableAddressable, UniqueBundleName);
|
||||
collectResult.SetCollectAssets(package.GetAllCollectAssets(command));
|
||||
return collectResult;
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception($"Not found collector pacakge : {packageName}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有包裹收集的资源文件
|
||||
/// </summary>
|
||||
public List<CollectAssetInfo> GetAllPackageAssets(EBuildMode buildMode)
|
||||
public List<CollectResult> GetAllPackageAssets(EBuildMode buildMode)
|
||||
{
|
||||
List<CollectAssetInfo> result = new List<CollectAssetInfo>(1000);
|
||||
List<CollectResult> collectResultList = new List<CollectResult>(1000);
|
||||
foreach (var package in Packages)
|
||||
{
|
||||
var temper = package.GetAllCollectAssets(buildMode, EnableAddressable);
|
||||
result.AddRange(temper);
|
||||
CollectCommand command = new CollectCommand(buildMode, EnableAddressable);
|
||||
CollectResult collectResult = new CollectResult(package.PackageName, EnableAddressable, UniqueBundleName);
|
||||
collectResult.SetCollectAssets(package.GetAllCollectAssets(command));
|
||||
collectResultList.Add(collectResult);
|
||||
}
|
||||
return result;
|
||||
return collectResultList;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -347,14 +347,20 @@ namespace YooAsset.Editor
|
||||
Setting.EnableAddressable = enableAddressable;
|
||||
IsDirty = true;
|
||||
}
|
||||
public static void ModifyUniqueBundleName(bool uniqueBundleName)
|
||||
{
|
||||
Setting.UniqueBundleName = uniqueBundleName;
|
||||
IsDirty = true;
|
||||
}
|
||||
|
||||
// 资源包裹编辑相关
|
||||
public static void CreatePackage(string packageName)
|
||||
public static AssetBundleCollectorPackage CreatePackage(string packageName)
|
||||
{
|
||||
AssetBundleCollectorPackage package = new AssetBundleCollectorPackage();
|
||||
package.PackageName = packageName;
|
||||
Setting.Packages.Add(package);
|
||||
IsDirty = true;
|
||||
return package;
|
||||
}
|
||||
public static void RemovePackage(AssetBundleCollectorPackage package)
|
||||
{
|
||||
@@ -376,12 +382,13 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
// 资源分组编辑相关
|
||||
public static void CreateGroup(AssetBundleCollectorPackage package, string groupName)
|
||||
public static AssetBundleCollectorGroup CreateGroup(AssetBundleCollectorPackage package, string groupName)
|
||||
{
|
||||
AssetBundleCollectorGroup group = new AssetBundleCollectorGroup();
|
||||
group.GroupName = groupName;
|
||||
package.Groups.Add(group);
|
||||
IsDirty = true;
|
||||
return group;
|
||||
}
|
||||
public static void RemoveGroup(AssetBundleCollectorPackage package, AssetBundleCollectorGroup group)
|
||||
{
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace YooAsset.Editor
|
||||
|
||||
private Toggle _showPackageToogle;
|
||||
private Toggle _enableAddressableToogle;
|
||||
private Toggle _uniqueBundleNameToogle;
|
||||
|
||||
private VisualElement _packageContainer;
|
||||
private ListView _packageListView;
|
||||
@@ -87,6 +88,12 @@ namespace YooAsset.Editor
|
||||
AssetBundleCollectorSettingData.ModifyAddressable(evt.newValue);
|
||||
RefreshWindow();
|
||||
});
|
||||
_uniqueBundleNameToogle = root.Q<Toggle>("UniqueBundleName");
|
||||
_uniqueBundleNameToogle.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleCollectorSettingData.ModifyUniqueBundleName(evt.newValue);
|
||||
RefreshWindow();
|
||||
});
|
||||
|
||||
// 配置修复按钮
|
||||
var fixBtn = root.Q<Button>("FixButton");
|
||||
@@ -289,6 +296,7 @@ namespace YooAsset.Editor
|
||||
private void FixBtn_clicked()
|
||||
{
|
||||
AssetBundleCollectorSettingData.FixFile();
|
||||
RefreshWindow();
|
||||
}
|
||||
private void ExportBtn_clicked()
|
||||
{
|
||||
@@ -733,8 +741,8 @@ namespace YooAsset.Editor
|
||||
|
||||
try
|
||||
{
|
||||
bool enableAdressable = AssetBundleCollectorSettingData.Setting.EnableAddressable;
|
||||
collectAssetInfos = collector.GetAllCollectAssets(EBuildMode.DryRunBuild, enableAdressable, group);
|
||||
CollectCommand command = new CollectCommand(EBuildMode.DryRunBuild, _enableAddressableToogle.value);
|
||||
collectAssetInfos = collector.GetAllCollectAssets(command, group);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<ui:VisualElement name="PublicContainer" style="height: 30px; background-color: rgb(67, 67, 67); flex-direction: row; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||
<ui:Toggle label="Show Packages" name="ShowPackages" style="width: 196px; -unity-text-align: middle-left;" />
|
||||
<ui:Toggle label="Enable Addressable" name="EnableAddressable" style="width: 196px; -unity-text-align: middle-left;" />
|
||||
<ui:Toggle label="Unique Bundle Name" name="UniqueBundleName" style="width: 196px; -unity-text-align: middle-left;" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="ContentContainer" style="flex-grow: 1; flex-direction: row;">
|
||||
<ui:VisualElement name="PackageContainer" style="width: 200px; flex-grow: 0; background-color: rgb(67, 67, 67); border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||
|
||||
@@ -50,5 +50,13 @@ namespace YooAsset.Editor
|
||||
AssetTags = assetTags;
|
||||
IsRawAsset = isRawAsset;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名称追加包裹名
|
||||
/// </summary>
|
||||
public void BundleNameAppendPackageName(string packageName)
|
||||
{
|
||||
BundleName = $"{packageName.ToLower()}_{BundleName}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class CollectCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// 构建模式
|
||||
/// </summary>
|
||||
public EBuildMode BuildMode { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用可寻址资源定位
|
||||
/// </summary>
|
||||
public bool EnableAddressable { private set; get; }
|
||||
|
||||
public CollectCommand(EBuildMode buildMode, bool enableAddressable)
|
||||
{
|
||||
BuildMode = buildMode;
|
||||
EnableAddressable = enableAddressable;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 057a358d2d0c92b47add59dac8bef783
|
||||
guid: b1741e85d76b28d41a4da3cd0e3e6f20
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
49
Assets/YooAsset/Editor/AssetBundleCollector/CollectResult.cs
Normal file
49
Assets/YooAsset/Editor/AssetBundleCollector/CollectResult.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class CollectResult
|
||||
{
|
||||
/// <summary>
|
||||
/// 包裹名称
|
||||
/// </summary>
|
||||
public string PackageName { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用可寻址资源定位
|
||||
/// </summary>
|
||||
public bool EnableAddressable { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名唯一化
|
||||
/// </summary>
|
||||
public bool UniqueBundleName { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 收集的资源信息列表
|
||||
/// </summary>
|
||||
public List<CollectAssetInfo> CollectAssets { private set; get; }
|
||||
|
||||
|
||||
public CollectResult(string packageName, bool enableAddressable, bool uniqueBundleName)
|
||||
{
|
||||
PackageName = packageName;
|
||||
EnableAddressable = enableAddressable;
|
||||
UniqueBundleName = uniqueBundleName;
|
||||
}
|
||||
|
||||
public void SetCollectAssets(List<CollectAssetInfo> collectAssets)
|
||||
{
|
||||
CollectAssets = collectAssets;
|
||||
|
||||
if (UniqueBundleName)
|
||||
{
|
||||
foreach (var collectAsset in CollectAssets)
|
||||
{
|
||||
collectAsset.BundleNameAppendPackageName(PackageName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a8d6592eded144142afcf85c79cf1ce4
|
||||
guid: dbbd465f929ee33408441b62d19c7d10
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -40,7 +40,7 @@ namespace YooAsset.Editor
|
||||
_visualAsset = EditorHelper.LoadWindowUXML<ReporterSummaryViewer>();
|
||||
if (_visualAsset == null)
|
||||
return;
|
||||
|
||||
|
||||
_root = _visualAsset.CloneTree();
|
||||
_root.style.flexGrow = 1f;
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace YooAsset.Editor
|
||||
public void FillViewData(BuildReport buildReport)
|
||||
{
|
||||
_buildReport = buildReport;
|
||||
|
||||
|
||||
_items.Clear();
|
||||
|
||||
_items.Add(new ItemWrapper("YooAsset版本", buildReport.Summary.YooVersion));
|
||||
@@ -69,6 +69,7 @@ namespace YooAsset.Editor
|
||||
_items.Add(new ItemWrapper("构建包裹", $"{buildReport.Summary.BuildPackage}"));
|
||||
|
||||
_items.Add(new ItemWrapper("启用可寻址资源定位", $"{buildReport.Summary.EnableAddressable}"));
|
||||
_items.Add(new ItemWrapper("资源包名唯一化", $"{buildReport.Summary.UniqueBundleName}"));
|
||||
_items.Add(new ItemWrapper("加密服务类名称", $"{buildReport.Summary.EncryptionServicesClassName}"));
|
||||
|
||||
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace YooAsset.Editor
|
||||
throw new System.Exception("Shader variant file extension is invalid.");
|
||||
|
||||
// 注意:先删除再保存,否则ShaderVariantCollection内容将无法及时刷新
|
||||
AssetDatabase.DeleteAsset(ShaderVariantCollectorSettingData.Setting.SavePath);
|
||||
AssetDatabase.DeleteAsset(ShaderVariantCollectorSettingData.Setting.SavePath);
|
||||
EditorTools.CreateFileDirectory(saveFilePath);
|
||||
_saveFilePath = saveFilePath;
|
||||
_completedCallback = completedCallback;
|
||||
@@ -87,9 +87,14 @@ namespace YooAsset.Editor
|
||||
List<string> allAssets = new List<string>(1000);
|
||||
|
||||
// 获取所有打包的资源
|
||||
List<CollectAssetInfo> allCollectInfos = AssetBundleCollectorSettingData.Setting.GetAllPackageAssets(EBuildMode.DryRunBuild);
|
||||
List<string> collectAssets = allCollectInfos.Select(t => t.AssetPath).ToList();
|
||||
foreach (var assetPath in collectAssets)
|
||||
List<CollectAssetInfo> allCollectAssetInfos = new List<CollectAssetInfo>();
|
||||
List<CollectResult> collectResults = AssetBundleCollectorSettingData.Setting.GetAllPackageAssets(EBuildMode.DryRunBuild);
|
||||
foreach (var collectResult in collectResults)
|
||||
{
|
||||
allCollectAssetInfos.AddRange(collectResult.CollectAssets);
|
||||
}
|
||||
List<string> allAssetPath = allCollectAssetInfos.Select(t => t.AssetPath).ToList();
|
||||
foreach (var assetPath in allAssetPath)
|
||||
{
|
||||
string[] depends = AssetDatabase.GetDependencies(assetPath, true);
|
||||
foreach (var depend in depends)
|
||||
@@ -97,7 +102,7 @@ namespace YooAsset.Editor
|
||||
if (allAssets.Contains(depend) == false)
|
||||
allAssets.Add(depend);
|
||||
}
|
||||
EditorTools.DisplayProgressBar("获取所有打包资源", ++progressValue, collectAssets.Count);
|
||||
EditorTools.DisplayProgressBar("获取所有打包资源", ++progressValue, allAssetPath.Count);
|
||||
}
|
||||
EditorTools.ClearProgressBar();
|
||||
|
||||
|
||||
@@ -142,6 +142,7 @@ namespace YooAsset
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
{
|
||||
YooLogger.Error($"Failed to load scene. {assetInfo.Error}");
|
||||
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
|
||||
completedProvider.SetCompleted(assetInfo.Error);
|
||||
return completedProvider.CreateHandle<SceneOperationHandle>();
|
||||
@@ -190,6 +191,7 @@ namespace YooAsset
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
{
|
||||
YooLogger.Error($"Failed to load asset. {assetInfo.Error}");
|
||||
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
|
||||
completedProvider.SetCompleted(assetInfo.Error);
|
||||
return completedProvider.CreateHandle<AssetOperationHandle>();
|
||||
@@ -216,6 +218,7 @@ namespace YooAsset
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
{
|
||||
YooLogger.Error($"Failed to load sub assets. {assetInfo.Error}");
|
||||
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
|
||||
completedProvider.SetCompleted(assetInfo.Error);
|
||||
return completedProvider.CreateHandle<SubAssetsOperationHandle>();
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace YooAsset
|
||||
/// <returns></returns>
|
||||
public GameObject InstantiateSync(Transform parent = null)
|
||||
{
|
||||
return InstantiateSyncInternal(Vector3.zero, Quaternion.identity, parent, false);
|
||||
return InstantiateSyncInternal(Vector3.zero, Quaternion.identity, parent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -98,7 +98,7 @@ namespace YooAsset
|
||||
/// <param name="parent">父类对象</param>
|
||||
public GameObject InstantiateSync(Vector3 position, Quaternion rotation, Transform parent = null)
|
||||
{
|
||||
return InstantiateSyncInternal(position, rotation, parent, true);
|
||||
return InstantiateSyncInternal(position, rotation, parent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -107,7 +107,7 @@ namespace YooAsset
|
||||
/// <param name="parent">父类对象</param>
|
||||
public InstantiateOperation InstantiateAsync(Transform parent = null)
|
||||
{
|
||||
return InstantiateAsyncInternal(Vector3.zero, Quaternion.identity, parent, false);
|
||||
return InstantiateAsyncInternal(Vector3.zero, Quaternion.identity, parent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -118,37 +118,23 @@ namespace YooAsset
|
||||
/// <param name="parent">父类对象</param>
|
||||
public InstantiateOperation InstantiateAsync(Vector3 position, Quaternion rotation, Transform parent = null)
|
||||
{
|
||||
return InstantiateAsyncInternal(position, rotation, parent, true);
|
||||
return InstantiateAsyncInternal(position, rotation, parent);
|
||||
}
|
||||
|
||||
|
||||
private GameObject InstantiateSyncInternal(Vector3 position, Quaternion rotation, Transform parent, bool setPositionRotation)
|
||||
private GameObject InstantiateSyncInternal(Vector3 position, Quaternion rotation, Transform parent)
|
||||
{
|
||||
if (IsValid == false)
|
||||
return null;
|
||||
if (Provider.AssetObject == null)
|
||||
return null;
|
||||
|
||||
GameObject result;
|
||||
if (setPositionRotation)
|
||||
{
|
||||
if (parent == null)
|
||||
result = UnityEngine.Object.Instantiate(Provider.AssetObject as GameObject, position, rotation);
|
||||
else
|
||||
result = UnityEngine.Object.Instantiate(Provider.AssetObject as GameObject, position, rotation, parent);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (parent == null)
|
||||
result = UnityEngine.Object.Instantiate(Provider.AssetObject as GameObject);
|
||||
else
|
||||
result = UnityEngine.Object.Instantiate(Provider.AssetObject as GameObject, parent);
|
||||
}
|
||||
return result;
|
||||
GameObject clone = UnityEngine.Object.Instantiate(Provider.AssetObject as GameObject, position, rotation, parent);
|
||||
return clone;
|
||||
}
|
||||
private InstantiateOperation InstantiateAsyncInternal(Vector3 position, Quaternion rotation, Transform parent, bool setPositionRotation)
|
||||
private InstantiateOperation InstantiateAsyncInternal(Vector3 position, Quaternion rotation, Transform parent)
|
||||
{
|
||||
InstantiateOperation operation = new InstantiateOperation(this, position, rotation, parent, setPositionRotation);
|
||||
InstantiateOperation operation = new InstantiateOperation(this, position, rotation, parent);
|
||||
OperationSystem.StartOperation(operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace YooAsset
|
||||
private readonly Vector3 _position;
|
||||
private readonly Quaternion _rotation;
|
||||
private readonly Transform _parent;
|
||||
private readonly bool _setPositionRotation;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
/// <summary>
|
||||
@@ -24,13 +23,12 @@ namespace YooAsset
|
||||
public GameObject Result = null;
|
||||
|
||||
|
||||
internal InstantiateOperation(AssetOperationHandle handle, Vector3 position, Quaternion rotation, Transform parent, bool setPositionRotation)
|
||||
internal InstantiateOperation(AssetOperationHandle handle, Vector3 position, Quaternion rotation, Transform parent)
|
||||
{
|
||||
_handle = handle;
|
||||
_position = position;
|
||||
_rotation = rotation;
|
||||
_parent = parent;
|
||||
_setPositionRotation = setPositionRotation;
|
||||
}
|
||||
internal override void Start()
|
||||
{
|
||||
@@ -62,24 +60,36 @@ namespace YooAsset
|
||||
return;
|
||||
}
|
||||
|
||||
if(_setPositionRotation)
|
||||
{
|
||||
if (_parent == null)
|
||||
Result = Object.Instantiate(_handle.AssetObject as GameObject, _position, _rotation);
|
||||
else
|
||||
Result = Object.Instantiate(_handle.AssetObject as GameObject, _position, _rotation, _parent);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_parent == null)
|
||||
Result = Object.Instantiate(_handle.AssetObject as GameObject);
|
||||
else
|
||||
Result = Object.Instantiate(_handle.AssetObject as GameObject, _parent);
|
||||
}
|
||||
// 实例化游戏对象
|
||||
Result = Object.Instantiate(_handle.AssetObject as GameObject, _position, _rotation, _parent);
|
||||
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取消实例化对象操作
|
||||
/// </summary>
|
||||
public void Cancel()
|
||||
{
|
||||
if (IsDone == false)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"User cancelled !";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 等待异步实例化结束
|
||||
/// </summary>
|
||||
public void WaitForAsyncComplete()
|
||||
{
|
||||
if (_steps == ESteps.Done)
|
||||
return;
|
||||
_handle.WaitForAsyncComplete();
|
||||
Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,14 +6,13 @@ using UnityEngine.SceneManagement;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
public class YooAssetPackage
|
||||
public class AssetsPackage
|
||||
{
|
||||
private bool _isInitialize = false;
|
||||
private string _initializeError = string.Empty;
|
||||
private EOperationStatus _initializeStatus = EOperationStatus.None;
|
||||
private EPlayMode _playMode;
|
||||
private IBundleServices _bundleServices;
|
||||
private ILocationServices _locationServices;
|
||||
private AssetSystemImpl _assetSystemImpl;
|
||||
private EditorSimulateModeImpl _editorSimulateModeImpl;
|
||||
private OfflinePlayModeImpl _offlinePlayModeImpl;
|
||||
@@ -25,21 +24,18 @@ namespace YooAsset
|
||||
public string PackageName { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否已经初始化
|
||||
/// 初始化状态
|
||||
/// </summary>
|
||||
public bool IsInitialized
|
||||
public EOperationStatus InitializeStatus
|
||||
{
|
||||
get { return _isInitialize; }
|
||||
get { return _initializeStatus; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 拒绝外部实例化
|
||||
/// </summary>
|
||||
internal YooAssetPackage()
|
||||
private AssetsPackage()
|
||||
{
|
||||
}
|
||||
internal YooAssetPackage(string packageName)
|
||||
internal AssetsPackage(string packageName)
|
||||
{
|
||||
PackageName = packageName;
|
||||
}
|
||||
@@ -65,7 +61,6 @@ namespace YooAsset
|
||||
_initializeStatus = EOperationStatus.None;
|
||||
|
||||
_bundleServices = null;
|
||||
_locationServices = null;
|
||||
_editorSimulateModeImpl = null;
|
||||
_offlinePlayModeImpl = null;
|
||||
_hostPlayModeImpl = null;
|
||||
@@ -75,8 +70,6 @@ namespace YooAsset
|
||||
_assetSystemImpl.DestroyAll();
|
||||
_assetSystemImpl = null;
|
||||
}
|
||||
|
||||
YooLogger.Log("YooAssets destroy all !");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +83,6 @@ namespace YooAsset
|
||||
|
||||
// 初始化资源系统
|
||||
InitializationOperation initializeOperation;
|
||||
_locationServices = parameters.LocationServices;
|
||||
_assetSystemImpl = new AssetSystemImpl();
|
||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||
{
|
||||
@@ -136,24 +128,21 @@ namespace YooAsset
|
||||
private void CheckInitializeParameters(InitializeParameters parameters)
|
||||
{
|
||||
if (_isInitialize)
|
||||
throw new Exception($"{nameof(YooAssetPackage)} is initialized yet.");
|
||||
throw new Exception($"{nameof(AssetsPackage)} is initialized yet.");
|
||||
|
||||
if (parameters == null)
|
||||
throw new Exception($"{nameof(YooAssetPackage)} create parameters is null.");
|
||||
throw new Exception($"{nameof(AssetsPackage)} create parameters is null.");
|
||||
|
||||
#if !UNITY_EDITOR
|
||||
if (parameters is EditorSimulateModeParameters)
|
||||
throw new Exception($"Editor simulate mode only support unity editor.");
|
||||
#endif
|
||||
|
||||
if (parameters.LocationServices == null)
|
||||
throw new Exception($"{nameof(ILocationServices)} is null.");
|
||||
|
||||
if(parameters is EditorSimulateModeParameters)
|
||||
if (parameters is EditorSimulateModeParameters)
|
||||
{
|
||||
var editorSimulateModeParameters = parameters as EditorSimulateModeParameters;
|
||||
if (string.IsNullOrEmpty(editorSimulateModeParameters.SimulatePatchManifestPath))
|
||||
throw new Exception($"${editorSimulateModeParameters.SimulatePatchManifestPath} is null or empty.");
|
||||
throw new Exception($"{nameof(editorSimulateModeParameters.SimulatePatchManifestPath)} is null or empty.");
|
||||
}
|
||||
|
||||
if (parameters is HostPlayModeParameters)
|
||||
@@ -280,6 +269,30 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取人类可读的版本信息
|
||||
/// </summary>
|
||||
public string GetHumanReadableVersion()
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||
{
|
||||
return _editorSimulateModeImpl.GetHumanReadableVersion();
|
||||
}
|
||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||
{
|
||||
return _offlinePlayModeImpl.GetHumanReadableVersion();
|
||||
}
|
||||
else if (_playMode == EPlayMode.HostPlayMode)
|
||||
{
|
||||
return _hostPlayModeImpl.GetHumanReadableVersion();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源回收(卸载引用计数为零的资源)
|
||||
/// </summary>
|
||||
@@ -314,7 +327,10 @@ namespace YooAsset
|
||||
DebugCheckInitialize();
|
||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
||||
if (assetInfo.IsInvalid)
|
||||
{
|
||||
YooLogger.Warning(assetInfo.Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
|
||||
if (bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
|
||||
@@ -376,14 +392,14 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源路径
|
||||
/// 检查资源定位地址是否有效
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
/// <returns>如果location地址无效,则返回空字符串</returns>
|
||||
public string GetAssetPath(string location)
|
||||
public bool CheckLocationValid(string location)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return _locationServices.ConvertLocationToAssetPath(this, location);
|
||||
string assetPath = _bundleServices.TryMappingToAssetPath(location);
|
||||
return string.IsNullOrEmpty(assetPath) == false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -408,8 +424,6 @@ namespace YooAsset
|
||||
public RawFileOperation GetRawFileAsync(AssetInfo assetInfo, string copyPath = null)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
if (assetInfo.IsInvalid)
|
||||
YooLogger.Warning(assetInfo.Error);
|
||||
return GetRawFileInternal(assetInfo, copyPath);
|
||||
}
|
||||
|
||||
@@ -418,6 +432,7 @@ namespace YooAsset
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
{
|
||||
YooLogger.Error($"Failed to get raw file. {assetInfo.Error}");
|
||||
RawFileOperation operation = new CompletedRawFileOperation(assetInfo.Error, copyPath);
|
||||
OperationSystem.StartOperation(operation);
|
||||
return operation;
|
||||
@@ -487,8 +502,6 @@ namespace YooAsset
|
||||
public SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
if (assetInfo.IsInvalid)
|
||||
YooLogger.Warning(assetInfo.Error);
|
||||
var handle = _assetSystemImpl.LoadSceneAsync(assetInfo, sceneMode, activateOnLoad, priority);
|
||||
return handle;
|
||||
}
|
||||
@@ -502,8 +515,6 @@ namespace YooAsset
|
||||
public AssetOperationHandle LoadAssetSync(AssetInfo assetInfo)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
if (assetInfo.IsInvalid)
|
||||
YooLogger.Warning(assetInfo.Error);
|
||||
return LoadAssetInternal(assetInfo, true);
|
||||
}
|
||||
|
||||
@@ -539,8 +550,6 @@ namespace YooAsset
|
||||
public AssetOperationHandle LoadAssetAsync(AssetInfo assetInfo)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
if (assetInfo.IsInvalid)
|
||||
YooLogger.Warning(assetInfo.Error);
|
||||
return LoadAssetInternal(assetInfo, false);
|
||||
}
|
||||
|
||||
@@ -572,14 +581,17 @@ namespace YooAsset
|
||||
private AssetOperationHandle LoadAssetInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
|
||||
if (bundleInfo.Bundle.IsRawFile)
|
||||
if (assetInfo.IsInvalid == false)
|
||||
{
|
||||
string error = $"Cannot load raw file using LoadAsset method !";
|
||||
YooLogger.Error(error);
|
||||
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
|
||||
completedProvider.SetCompleted(error);
|
||||
return completedProvider.CreateHandle<AssetOperationHandle>();
|
||||
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
|
||||
if (bundleInfo.Bundle.IsRawFile)
|
||||
{
|
||||
string error = $"Cannot load raw file using LoadAsset method !";
|
||||
YooLogger.Error(error);
|
||||
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
|
||||
completedProvider.SetCompleted(error);
|
||||
return completedProvider.CreateHandle<AssetOperationHandle>();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -598,8 +610,6 @@ namespace YooAsset
|
||||
public SubAssetsOperationHandle LoadSubAssetsSync(AssetInfo assetInfo)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
if (assetInfo.IsInvalid)
|
||||
YooLogger.Warning(assetInfo.Error);
|
||||
return LoadSubAssetsInternal(assetInfo, true);
|
||||
}
|
||||
|
||||
@@ -635,8 +645,6 @@ namespace YooAsset
|
||||
public SubAssetsOperationHandle LoadSubAssetsAsync(AssetInfo assetInfo)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
if (assetInfo.IsInvalid)
|
||||
YooLogger.Warning(assetInfo.Error);
|
||||
return LoadSubAssetsInternal(assetInfo, false);
|
||||
}
|
||||
|
||||
@@ -668,14 +676,17 @@ namespace YooAsset
|
||||
private SubAssetsOperationHandle LoadSubAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
|
||||
if (bundleInfo.Bundle.IsRawFile)
|
||||
if (assetInfo.IsInvalid == false)
|
||||
{
|
||||
string error = $"Cannot load raw file using LoadSubAssets method !";
|
||||
YooLogger.Error(error);
|
||||
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
|
||||
completedProvider.SetCompleted(error);
|
||||
return completedProvider.CreateHandle<SubAssetsOperationHandle>();
|
||||
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
|
||||
if (bundleInfo.Bundle.IsRawFile)
|
||||
{
|
||||
string error = $"Cannot load raw file using LoadSubAssets method !";
|
||||
YooLogger.Error(error);
|
||||
CompletedProvider completedProvider = new CompletedProvider(assetInfo);
|
||||
completedProvider.SetCompleted(error);
|
||||
return completedProvider.CreateHandle<SubAssetsOperationHandle>();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -693,10 +704,11 @@ namespace YooAsset
|
||||
/// <param name="tag">资源标签</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
public PatchDownloaderOperation CreatePatchDownloader(string tag, int downloadingMaxNumber, int failedTryAgain)
|
||||
/// <param name="timeout">超时时间</param>
|
||||
public PatchDownloaderOperation CreatePatchDownloader(string tag, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return CreatePatchDownloader(new string[] { tag }, downloadingMaxNumber, failedTryAgain);
|
||||
return CreatePatchDownloader(new string[] { tag }, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -705,18 +717,19 @@ namespace YooAsset
|
||||
/// <param name="tags">资源标签列表</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
public PatchDownloaderOperation CreatePatchDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain)
|
||||
/// <param name="timeout">超时时间</param>
|
||||
public PatchDownloaderOperation CreatePatchDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
if (_playMode == EPlayMode.EditorSimulateMode || _playMode == EPlayMode.OfflinePlayMode)
|
||||
{
|
||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
else if (_playMode == EPlayMode.HostPlayMode)
|
||||
{
|
||||
return _hostPlayModeImpl.CreatePatchDownloaderByTags(tags, downloadingMaxNumber, failedTryAgain);
|
||||
return _hostPlayModeImpl.CreatePatchDownloaderByTags(tags, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -729,18 +742,19 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
public PatchDownloaderOperation CreatePatchDownloader(int downloadingMaxNumber, int failedTryAgain)
|
||||
/// <param name="timeout">超时时间</param>
|
||||
public PatchDownloaderOperation CreatePatchDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
if (_playMode == EPlayMode.EditorSimulateMode || _playMode == EPlayMode.OfflinePlayMode)
|
||||
{
|
||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
else if (_playMode == EPlayMode.HostPlayMode)
|
||||
{
|
||||
return _hostPlayModeImpl.CreatePatchDownloaderByAll(downloadingMaxNumber, failedTryAgain);
|
||||
return _hostPlayModeImpl.CreatePatchDownloaderByAll(downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -755,13 +769,14 @@ namespace YooAsset
|
||||
/// <param name="locations">资源定位列表</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
public PatchDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain)
|
||||
/// <param name="timeout">超时时间</param>
|
||||
public PatchDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
if (_playMode == EPlayMode.EditorSimulateMode || _playMode == EPlayMode.OfflinePlayMode)
|
||||
{
|
||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
else if (_playMode == EPlayMode.HostPlayMode)
|
||||
@@ -772,7 +787,7 @@ namespace YooAsset
|
||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
||||
assetInfos.Add(assetInfo);
|
||||
}
|
||||
return _hostPlayModeImpl.CreatePatchDownloaderByPaths(assetInfos.ToArray(), downloadingMaxNumber, failedTryAgain);
|
||||
return _hostPlayModeImpl.CreatePatchDownloaderByPaths(assetInfos.ToArray(), downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -786,18 +801,19 @@ namespace YooAsset
|
||||
/// <param name="assetInfos">资源信息列表</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
public PatchDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain)
|
||||
/// <param name="timeout">超时时间</param>
|
||||
public PatchDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
if (_playMode == EPlayMode.EditorSimulateMode || _playMode == EPlayMode.OfflinePlayMode)
|
||||
{
|
||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
else if (_playMode == EPlayMode.HostPlayMode)
|
||||
{
|
||||
return _hostPlayModeImpl.CreatePatchDownloaderByPaths(assetInfos, downloadingMaxNumber, failedTryAgain);
|
||||
return _hostPlayModeImpl.CreatePatchDownloaderByPaths(assetInfos, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -831,18 +847,18 @@ namespace YooAsset
|
||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||
{
|
||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||
var operation = new PatchUnpackerOperation(downloadList, unpackingMaxNumber, failedTryAgain);
|
||||
var operation = new PatchUnpackerOperation(downloadList, unpackingMaxNumber, failedTryAgain, int.MaxValue);
|
||||
return operation;
|
||||
}
|
||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||
{
|
||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||
var operation = new PatchUnpackerOperation(downloadList, unpackingMaxNumber, failedTryAgain);
|
||||
var operation = new PatchUnpackerOperation(downloadList, unpackingMaxNumber, failedTryAgain, int.MaxValue);
|
||||
return operation;
|
||||
}
|
||||
else if (_playMode == EPlayMode.HostPlayMode)
|
||||
{
|
||||
return _hostPlayModeImpl.CreatePatchUnpackerByTags(tags, unpackingMaxNumber, failedTryAgain);
|
||||
return _hostPlayModeImpl.CreatePatchUnpackerByTags(tags, unpackingMaxNumber, failedTryAgain, int.MaxValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -861,18 +877,18 @@ namespace YooAsset
|
||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||
{
|
||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||
var operation = new PatchUnpackerOperation(downloadList, unpackingMaxNumber, failedTryAgain);
|
||||
var operation = new PatchUnpackerOperation(downloadList, unpackingMaxNumber, failedTryAgain, int.MaxValue);
|
||||
return operation;
|
||||
}
|
||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||
{
|
||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||
var operation = new PatchUnpackerOperation(downloadList, unpackingMaxNumber, failedTryAgain);
|
||||
var operation = new PatchUnpackerOperation(downloadList, unpackingMaxNumber, failedTryAgain, int.MaxValue);
|
||||
return operation;
|
||||
}
|
||||
else if (_playMode == EPlayMode.HostPlayMode)
|
||||
{
|
||||
return _hostPlayModeImpl.CreatePatchUnpackerByAll(unpackingMaxNumber, failedTryAgain);
|
||||
return _hostPlayModeImpl.CreatePatchUnpackerByAll(unpackingMaxNumber, failedTryAgain, int.MaxValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -915,11 +931,14 @@ namespace YooAsset
|
||||
|
||||
#region 内部方法
|
||||
/// <summary>
|
||||
/// 资源定位地址转换为资源完整路径
|
||||
/// 是否包含资源文件
|
||||
/// </summary>
|
||||
internal string MappingToAssetPath(string location)
|
||||
internal bool IsIncludeBundleFile(string fileName)
|
||||
{
|
||||
return _bundleServices.MappingToAssetPath(location);
|
||||
// NOTE : 编辑器模拟模式下始终返回TRUE
|
||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||
return true;
|
||||
return _bundleServices.IsIncludeBundleFile(fileName);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -977,7 +996,7 @@ namespace YooAsset
|
||||
private AssetInfo ConvertLocationToAssetInfo(string location, System.Type assetType)
|
||||
{
|
||||
DebugCheckLocation(location);
|
||||
string assetPath = _locationServices.ConvertLocationToAssetPath(this, location);
|
||||
string assetPath = _bundleServices.MappingToAssetPath(location);
|
||||
PatchAsset patchAsset = _bundleServices.TryGetPatchAsset(assetPath);
|
||||
if (patchAsset != null)
|
||||
{
|
||||
@@ -991,7 +1010,6 @@ namespace YooAsset
|
||||
error = $"The location is null or empty !";
|
||||
else
|
||||
error = $"The location is invalid : {location}";
|
||||
YooLogger.Error(error);
|
||||
AssetInfo assetInfo = new AssetInfo(error);
|
||||
return assetInfo;
|
||||
}
|
||||
181
Assets/YooAsset/Runtime/CacheSystem/CacheVerifier.cs
Normal file
181
Assets/YooAsset/Runtime/CacheSystem/CacheVerifier.cs
Normal file
@@ -0,0 +1,181 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 本地缓存文件验证器
|
||||
/// </summary>
|
||||
internal abstract class CacheVerifier
|
||||
{
|
||||
public abstract void InitVerifier(List<VerifyInfo> verifyInfos);
|
||||
public abstract bool UpdateVerifier();
|
||||
public abstract float GetVerifierProgress();
|
||||
|
||||
public List<VerifyInfo> VerifySuccessList { protected set; get; }
|
||||
public List<VerifyInfo> VerifyFailList { protected set; get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 本地缓存文件验证器(线程版)
|
||||
/// </summary>
|
||||
internal class CacheVerifierWithThread : CacheVerifier
|
||||
{
|
||||
private readonly ThreadSyncContext _syncContext = new ThreadSyncContext();
|
||||
private readonly List<VerifyInfo> _waitingList = new List<VerifyInfo>(1000);
|
||||
private readonly List<VerifyInfo> _verifyingList = new List<VerifyInfo>(100);
|
||||
private int _verifyMaxNum;
|
||||
private int _verifyTotalCount;
|
||||
|
||||
public override void InitVerifier(List<VerifyInfo> verifyInfos)
|
||||
{
|
||||
_waitingList.AddRange(verifyInfos);
|
||||
VerifySuccessList = new List<VerifyInfo>(verifyInfos.Count);
|
||||
VerifyFailList = new List<VerifyInfo>(verifyInfos.Count);
|
||||
|
||||
// 设置同时验证的最大数
|
||||
ThreadPool.GetMaxThreads(out int workerThreads, out int ioThreads);
|
||||
YooLogger.Log($"Work threads : {workerThreads}, IO threads : {ioThreads}");
|
||||
_verifyMaxNum = Math.Min(workerThreads, ioThreads);
|
||||
_verifyTotalCount = _waitingList.Count;
|
||||
if (_verifyMaxNum < 1)
|
||||
_verifyMaxNum = 1;
|
||||
}
|
||||
public override bool UpdateVerifier()
|
||||
{
|
||||
_syncContext.Update();
|
||||
|
||||
if (_waitingList.Count == 0 && _verifyingList.Count == 0)
|
||||
return true;
|
||||
|
||||
if (_verifyingList.Count >= _verifyMaxNum)
|
||||
return false;
|
||||
|
||||
for (int i = _waitingList.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (_verifyingList.Count >= _verifyMaxNum)
|
||||
break;
|
||||
|
||||
var verifyIno = _waitingList[i];
|
||||
if (VerifyFileWithThread(verifyIno))
|
||||
{
|
||||
_waitingList.RemoveAt(i);
|
||||
_verifyingList.Add(verifyIno);
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Warning("The thread pool is failed queued.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public override float GetVerifierProgress()
|
||||
{
|
||||
if (_verifyTotalCount == 0)
|
||||
return 1f;
|
||||
return (float)(VerifySuccessList.Count + VerifyFailList.Count) / _verifyTotalCount;
|
||||
}
|
||||
|
||||
private bool VerifyFileWithThread(VerifyInfo verifyInfo)
|
||||
{
|
||||
return ThreadPool.QueueUserWorkItem(new WaitCallback(VerifyInThread), verifyInfo);
|
||||
}
|
||||
private void VerifyInThread(object infoObj)
|
||||
{
|
||||
VerifyInfo verifyInfo = (VerifyInfo)infoObj;
|
||||
verifyInfo.Result = CacheSystem.VerifyBundle(verifyInfo.VerifyBundle, CacheSystem.InitVerifyLevel);
|
||||
_syncContext.Post(VerifyCallback, verifyInfo);
|
||||
}
|
||||
private void VerifyCallback(object obj)
|
||||
{
|
||||
VerifyInfo verifyIno = (VerifyInfo)obj;
|
||||
if (verifyIno.Result == EVerifyResult.Succeed)
|
||||
{
|
||||
VerifySuccessList.Add(verifyIno);
|
||||
CacheSystem.CacheBundle(verifyIno.VerifyBundle);
|
||||
}
|
||||
else
|
||||
{
|
||||
VerifyFailList.Add(verifyIno);
|
||||
|
||||
// NOTE:不期望删除断点续传的资源文件
|
||||
/*
|
||||
if (File.Exists(patchBundle.CachedBundleFilePath))
|
||||
File.Delete(patchBundle.CachedBundleFilePath);
|
||||
*/
|
||||
}
|
||||
_verifyingList.Remove(verifyIno);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 本地缓存文件验证器(非线程版)
|
||||
/// </summary>
|
||||
internal class CacheVerifierWithoutThread : CacheVerifier
|
||||
{
|
||||
private readonly List<VerifyInfo> _waitingList = new List<VerifyInfo>(1000);
|
||||
private readonly List<VerifyInfo> _verifyingList = new List<VerifyInfo>(100);
|
||||
private int _verifyMaxNum;
|
||||
private int _verifyTotalCount;
|
||||
|
||||
public override void InitVerifier(List<VerifyInfo> verifyInfos)
|
||||
{
|
||||
_waitingList.AddRange(verifyInfos);
|
||||
VerifySuccessList = new List<VerifyInfo>(verifyInfos.Count);
|
||||
VerifyFailList = new List<VerifyInfo>(verifyInfos.Count);
|
||||
|
||||
// 设置同时验证的最大数
|
||||
_verifyMaxNum = 32;
|
||||
_verifyTotalCount = _waitingList.Count;
|
||||
}
|
||||
public override bool UpdateVerifier()
|
||||
{
|
||||
if (_waitingList.Count == 0 && _verifyingList.Count == 0)
|
||||
return true;
|
||||
|
||||
for (int i = _waitingList.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (_verifyingList.Count >= _verifyMaxNum)
|
||||
break;
|
||||
|
||||
var verifyIno = _waitingList[i];
|
||||
VerifyFileWithoutThread(verifyIno);
|
||||
_waitingList.RemoveAt(i);
|
||||
_verifyingList.Add(verifyIno);
|
||||
}
|
||||
|
||||
_verifyingList.Clear();
|
||||
return false;
|
||||
}
|
||||
public override float GetVerifierProgress()
|
||||
{
|
||||
if (_verifyTotalCount == 0)
|
||||
return 1f;
|
||||
return (float)(VerifySuccessList.Count + VerifyFailList.Count) / _verifyTotalCount;
|
||||
}
|
||||
|
||||
private void VerifyFileWithoutThread(VerifyInfo verifyIno)
|
||||
{
|
||||
var verifyResult = CacheSystem.VerifyAndCacheBundle(verifyIno.VerifyBundle, CacheSystem.InitVerifyLevel);
|
||||
if (verifyResult == EVerifyResult.Succeed)
|
||||
{
|
||||
VerifySuccessList.Add(verifyIno);
|
||||
}
|
||||
else
|
||||
{
|
||||
VerifyFailList.Add(verifyIno);
|
||||
|
||||
// NOTE:不期望删除断点续传的资源文件
|
||||
/*
|
||||
if (File.Exists(patchBundle.CachedBundleFilePath))
|
||||
File.Delete(patchBundle.CachedBundleFilePath);
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,247 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 本地缓存文件验证器
|
||||
/// </summary>
|
||||
internal abstract class PatchCacheVerifier
|
||||
{
|
||||
public abstract bool InitVerifier(HostPlayModeImpl impl, bool weaklyUpdate);
|
||||
public abstract bool UpdateVerifier();
|
||||
public abstract float GetVerifierProgress();
|
||||
|
||||
public int VerifySuccessCount { protected set; get; } = 0;
|
||||
public int VerifyFailCount { protected set; get; } = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 本地缓存文件验证器(线程版)
|
||||
/// </summary>
|
||||
internal class PatchCacheVerifierWithThread : PatchCacheVerifier
|
||||
{
|
||||
private class ThreadInfo
|
||||
{
|
||||
public EVerifyResult Result;
|
||||
public string FilePath { private set; get; }
|
||||
public PatchBundle Bundle { private set; get; }
|
||||
public ThreadInfo(string filePath, PatchBundle bundle)
|
||||
{
|
||||
FilePath = filePath;
|
||||
Bundle = bundle;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly ThreadSyncContext _syncContext = new ThreadSyncContext();
|
||||
private readonly List<PatchBundle> _waitingList = new List<PatchBundle>(1000);
|
||||
private readonly List<PatchBundle> _verifyingList = new List<PatchBundle>(100);
|
||||
private int _verifyMaxNum;
|
||||
private int _verifyTotalCount;
|
||||
|
||||
public override bool InitVerifier(HostPlayModeImpl impl, bool weaklyUpdate)
|
||||
{
|
||||
// 遍历所有文件然后验证并缓存合法文件
|
||||
foreach (var patchBundle in impl.LocalPatchManifest.BundleList)
|
||||
{
|
||||
// 忽略缓存文件
|
||||
if (CacheSystem.IsCached(patchBundle))
|
||||
continue;
|
||||
|
||||
// 忽略APP资源
|
||||
if (impl.IsBuildinPatchBundle(patchBundle))
|
||||
continue;
|
||||
|
||||
// 注意:在弱联网模式下,我们需要验证指定资源版本的所有资源完整性
|
||||
if (weaklyUpdate)
|
||||
{
|
||||
string filePath = patchBundle.CachedFilePath;
|
||||
if (File.Exists(filePath))
|
||||
_waitingList.Add(patchBundle);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
string filePath = patchBundle.CachedFilePath;
|
||||
if (File.Exists(filePath))
|
||||
_waitingList.Add(patchBundle);
|
||||
}
|
||||
}
|
||||
|
||||
// 设置同时验证的最大数
|
||||
ThreadPool.GetMaxThreads(out int workerThreads, out int ioThreads);
|
||||
YooLogger.Log($"Work threads : {workerThreads}, IO threads : {ioThreads}");
|
||||
_verifyMaxNum = Math.Min(workerThreads, ioThreads);
|
||||
_verifyTotalCount = _waitingList.Count;
|
||||
if (_verifyMaxNum < 1)
|
||||
_verifyMaxNum = 1;
|
||||
return true;
|
||||
}
|
||||
public override bool UpdateVerifier()
|
||||
{
|
||||
_syncContext.Update();
|
||||
|
||||
if (_waitingList.Count == 0 && _verifyingList.Count == 0)
|
||||
return true;
|
||||
|
||||
if (_verifyingList.Count >= _verifyMaxNum)
|
||||
return false;
|
||||
|
||||
for (int i = _waitingList.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (_verifyingList.Count >= _verifyMaxNum)
|
||||
break;
|
||||
|
||||
var patchBundle = _waitingList[i];
|
||||
if (VerifyFile(patchBundle))
|
||||
{
|
||||
_waitingList.RemoveAt(i);
|
||||
_verifyingList.Add(patchBundle);
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Warning("The thread pool is failed queued.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public override float GetVerifierProgress()
|
||||
{
|
||||
if (_verifyTotalCount == 0)
|
||||
return 1f;
|
||||
return (float)(VerifySuccessCount + VerifyFailCount) / _verifyTotalCount;
|
||||
}
|
||||
|
||||
private bool VerifyFile(PatchBundle patchBundle)
|
||||
{
|
||||
string filePath = patchBundle.CachedFilePath;
|
||||
ThreadInfo info = new ThreadInfo(filePath, patchBundle);
|
||||
return ThreadPool.QueueUserWorkItem(new WaitCallback(VerifyInThread), info);
|
||||
}
|
||||
private void VerifyInThread(object infoObj)
|
||||
{
|
||||
ThreadInfo info = (ThreadInfo)infoObj;
|
||||
info.Result = CacheSystem.VerifyBundle(info.Bundle, CacheSystem.InitVerifyLevel);
|
||||
_syncContext.Post(VerifyCallback, info);
|
||||
}
|
||||
private void VerifyCallback(object obj)
|
||||
{
|
||||
ThreadInfo info = (ThreadInfo)obj;
|
||||
if (info.Result == EVerifyResult.Succeed)
|
||||
{
|
||||
VerifySuccessCount++;
|
||||
CacheSystem.CacheBundle(info.Bundle);
|
||||
}
|
||||
else
|
||||
{
|
||||
VerifyFailCount++;
|
||||
YooLogger.Warning($"Failed to verify file : {info.Bundle.CachedFilePath}");
|
||||
|
||||
// NOTE:不期望删除断点续传的资源文件
|
||||
/*
|
||||
if (File.Exists(patchBundle.CachedBundleFilePath))
|
||||
File.Delete(patchBundle.CachedBundleFilePath);
|
||||
*/
|
||||
}
|
||||
_verifyingList.Remove(info.Bundle);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 本地缓存文件验证器(非线程版)
|
||||
/// </summary>
|
||||
internal class PatchCacheVerifierWithoutThread : PatchCacheVerifier
|
||||
{
|
||||
private readonly List<PatchBundle> _waitingList = new List<PatchBundle>(1000);
|
||||
private readonly List<PatchBundle> _verifyingList = new List<PatchBundle>(100);
|
||||
private int _verifyMaxNum;
|
||||
private int _verifyTotalCount;
|
||||
|
||||
public override bool InitVerifier(HostPlayModeImpl impl, bool weaklyUpdate)
|
||||
{
|
||||
// 遍历所有文件然后验证并缓存合法文件
|
||||
foreach (var patchBundle in impl.LocalPatchManifest.BundleList)
|
||||
{
|
||||
// 忽略缓存文件
|
||||
if (CacheSystem.IsCached(patchBundle))
|
||||
continue;
|
||||
|
||||
// 忽略APP资源
|
||||
if (impl.IsBuildinPatchBundle(patchBundle))
|
||||
continue;
|
||||
|
||||
// 注意:在弱联网模式下,我们需要验证指定资源版本的所有资源完整性
|
||||
if (weaklyUpdate)
|
||||
{
|
||||
string filePath = patchBundle.CachedFilePath;
|
||||
if (File.Exists(filePath))
|
||||
_waitingList.Add(patchBundle);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
string filePath = patchBundle.CachedFilePath;
|
||||
if (File.Exists(filePath))
|
||||
_waitingList.Add(patchBundle);
|
||||
}
|
||||
}
|
||||
|
||||
// 设置同时验证的最大数
|
||||
_verifyMaxNum = 32;
|
||||
_verifyTotalCount = _waitingList.Count;
|
||||
return true;
|
||||
}
|
||||
public override bool UpdateVerifier()
|
||||
{
|
||||
if (_waitingList.Count == 0 && _verifyingList.Count == 0)
|
||||
return true;
|
||||
|
||||
for (int i = _waitingList.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (_verifyingList.Count >= _verifyMaxNum)
|
||||
break;
|
||||
|
||||
var patchBundle = _waitingList[i];
|
||||
VerifyFile(patchBundle);
|
||||
_waitingList.RemoveAt(i);
|
||||
_verifyingList.Add(patchBundle);
|
||||
}
|
||||
|
||||
_verifyingList.Clear();
|
||||
return false;
|
||||
}
|
||||
public override float GetVerifierProgress()
|
||||
{
|
||||
if (_verifyTotalCount == 0)
|
||||
return 1f;
|
||||
return (float)(VerifySuccessCount + VerifyFailCount) / _verifyTotalCount;
|
||||
}
|
||||
|
||||
private void VerifyFile(PatchBundle patchBundle)
|
||||
{
|
||||
var verifyResult = CacheSystem.VerifyAndCacheBundle(patchBundle, CacheSystem.InitVerifyLevel);
|
||||
if (verifyResult == EVerifyResult.Succeed)
|
||||
{
|
||||
VerifySuccessCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
VerifyFailCount++;
|
||||
YooLogger.Warning($"Failed to verify file : {patchBundle.CachedFilePath}");
|
||||
|
||||
// NOTE:不期望删除断点续传的资源文件
|
||||
/*
|
||||
if (File.Exists(patchBundle.CachedBundleFilePath))
|
||||
File.Delete(patchBundle.CachedBundleFilePath);
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
33
Assets/YooAsset/Runtime/CacheSystem/VerifyInfo.cs
Normal file
33
Assets/YooAsset/Runtime/CacheSystem/VerifyInfo.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class VerifyInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 验证的资源文件是否为内置资源
|
||||
/// </summary>
|
||||
public bool IsBuildinFile { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 验证的资源包实例
|
||||
/// </summary>
|
||||
public PatchBundle VerifyBundle { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 验证的文件路径
|
||||
/// </summary>
|
||||
public string VerifyFilePath { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 验证结果
|
||||
/// </summary>
|
||||
public EVerifyResult Result;
|
||||
|
||||
public VerifyInfo(bool isBuildinFile, PatchBundle verifyBundle)
|
||||
{
|
||||
IsBuildinFile = isBuildinFile;
|
||||
VerifyBundle = verifyBundle;
|
||||
VerifyFilePath = verifyBundle.CachedFilePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/YooAsset/Runtime/CacheSystem/VerifyInfo.cs.meta
Normal file
11
Assets/YooAsset/Runtime/CacheSystem/VerifyInfo.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6296859f09655c4191594304ddf378f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
@@ -15,11 +16,22 @@ namespace YooAsset
|
||||
private static readonly Dictionary<string, DownloaderBase> _downloaderDic = new Dictionary<string, DownloaderBase>();
|
||||
private static readonly List<string> _removeList = new List<string>(100);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 启用断点续传的文件大小
|
||||
/// 自定义的证书认证实例
|
||||
/// </summary>
|
||||
public static CertificateHandler CertificateHandlerInstance;
|
||||
|
||||
/// <summary>
|
||||
/// 启用断点续传功能文件的最小字节数
|
||||
/// </summary>
|
||||
public static int BreakpointResumeFileSize { set; get; } = int.MaxValue;
|
||||
|
||||
/// <summary>
|
||||
/// 下载失败后清理文件的HTTP错误码
|
||||
/// </summary>
|
||||
public static List<long> ClearFileResponseCodes { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新所有下载器
|
||||
/// </summary>
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 支持Unity2018版本的断点续传下载器
|
||||
/// </summary>
|
||||
public class DownloadHandlerFileRange : DownloadHandlerScript
|
||||
internal class DownloadHandlerFileRange : DownloadHandlerScript
|
||||
{
|
||||
private string _fileSavePath;
|
||||
private long _fileTotalSize;
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace YooAsset
|
||||
|
||||
// 重置变量
|
||||
private bool _isAbort = false;
|
||||
private ulong _fileOriginLength;
|
||||
private ulong _latestDownloadBytes;
|
||||
private float _latestDownloadRealtime;
|
||||
private float _tryAgainTimer;
|
||||
@@ -60,6 +61,7 @@ namespace YooAsset
|
||||
_downloadProgress = 0f;
|
||||
_downloadedBytes = 0;
|
||||
_isAbort = false;
|
||||
_fileOriginLength = 0;
|
||||
_latestDownloadBytes = 0;
|
||||
_latestDownloadRealtime = Time.realtimeSinceStartup;
|
||||
_tryAgainTimer = 0f;
|
||||
@@ -72,6 +74,8 @@ namespace YooAsset
|
||||
{
|
||||
FileInfo fileInfo = new FileInfo(fileSavePath);
|
||||
fileLength = fileInfo.Length;
|
||||
_fileOriginLength = (ulong)fileLength;
|
||||
_downloadedBytes = _fileOriginLength;
|
||||
}
|
||||
|
||||
_requestURL = GetRequestURL();
|
||||
@@ -85,6 +89,12 @@ namespace YooAsset
|
||||
_downloadHandle = handler;
|
||||
#endif
|
||||
|
||||
if (DownloadSystem.CertificateHandlerInstance != null)
|
||||
{
|
||||
_webRequest.certificateHandler = DownloadSystem.CertificateHandlerInstance;
|
||||
_webRequest.disposeCertificateHandlerOnDispose = false;
|
||||
}
|
||||
|
||||
_webRequest.downloadHandler = handler;
|
||||
_webRequest.disposeDownloadHandlerOnDispose = true;
|
||||
if (fileLength > 0)
|
||||
@@ -109,7 +119,7 @@ namespace YooAsset
|
||||
if (_steps == ESteps.CheckDownload)
|
||||
{
|
||||
_downloadProgress = _webRequest.downloadProgress;
|
||||
_downloadedBytes = _webRequest.downloadedBytes;
|
||||
_downloadedBytes = _fileOriginLength + _webRequest.downloadedBytes;
|
||||
if (_webRequest.isDone == false)
|
||||
{
|
||||
CheckTimeout();
|
||||
@@ -152,13 +162,26 @@ namespace YooAsset
|
||||
// 如果下载失败
|
||||
if (hasError)
|
||||
{
|
||||
// 注意:非断点续传下载失败后删除文件
|
||||
// 注意:非断点续传下载失败之后删除文件
|
||||
if (_breakResume == false)
|
||||
{
|
||||
string cacheFilePath = _bundleInfo.Bundle.CachedFilePath;
|
||||
if (File.Exists(cacheFilePath))
|
||||
File.Delete(cacheFilePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 注意:下载断点续传文件发生特殊错误码之后删除文件
|
||||
if (DownloadSystem.ClearFileResponseCodes != null)
|
||||
{
|
||||
if (DownloadSystem.ClearFileResponseCodes.Contains(_webRequest.responseCode))
|
||||
{
|
||||
string cacheFilePath = _bundleInfo.Bundle.CachedFilePath;
|
||||
if (File.Exists(cacheFilePath))
|
||||
File.Delete(cacheFilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 失败后重新尝试
|
||||
if (_failedTryAgain > 0)
|
||||
@@ -226,7 +249,7 @@ namespace YooAsset
|
||||
}
|
||||
private void DisposeWebRequest()
|
||||
{
|
||||
if(_downloadHandle != null)
|
||||
if (_downloadHandle != null)
|
||||
{
|
||||
_downloadHandle.Cleanup();
|
||||
_downloadHandle = null;
|
||||
|
||||
@@ -1,288 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Security;
|
||||
using System.Threading;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
/*
|
||||
internal sealed class HttpDownloader : DownloaderBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 多线程下载器
|
||||
/// </summary>
|
||||
private class ThreadDownloader
|
||||
{
|
||||
private const int BufferSize = 1042 * 4;
|
||||
|
||||
private Thread _thread;
|
||||
private bool _running = true;
|
||||
private string _url;
|
||||
private string _savePath;
|
||||
private long _fileSize;
|
||||
private int _timeout;
|
||||
|
||||
/// <summary>
|
||||
/// 下载是否结束
|
||||
/// </summary>
|
||||
public bool IsDone = false;
|
||||
|
||||
/// <summary>
|
||||
/// 错误日志
|
||||
/// </summary>
|
||||
public string Error = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 下载进度
|
||||
/// </summary>
|
||||
public float DownloadProgress = 0f;
|
||||
|
||||
/// <summary>
|
||||
/// 已经下载的总字节数
|
||||
/// </summary>
|
||||
public ulong DownloadedBytes = 0;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 开始下载
|
||||
/// </summary>
|
||||
public void Run(string url, string savePath, long fileSize, int timeout)
|
||||
{
|
||||
_url = url;
|
||||
_savePath = savePath;
|
||||
_fileSize = fileSize;
|
||||
_timeout = timeout;
|
||||
|
||||
_thread = new Thread(ThreadRun);
|
||||
_thread.IsBackground = true;
|
||||
_thread.Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 中断下载线程
|
||||
/// </summary>
|
||||
public void Abort()
|
||||
{
|
||||
_running = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下载结果
|
||||
/// </summary>
|
||||
public bool HasError()
|
||||
{
|
||||
if (string.IsNullOrEmpty(Error))
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
private void ThreadRun()
|
||||
{
|
||||
long fileTotalSize = _fileSize;
|
||||
|
||||
FileStream fileStream = null;
|
||||
HttpWebResponse webResponse = null;
|
||||
Stream responseStream = null;
|
||||
|
||||
try
|
||||
{
|
||||
// 创建文件流
|
||||
fileStream = new FileStream(_savePath, FileMode.OpenOrCreate, FileAccess.Write);
|
||||
long fileLength = fileStream.Length;
|
||||
|
||||
// 创建HTTP下载请求
|
||||
HttpWebRequest webRequest = WebRequest.Create(_url) as HttpWebRequest;
|
||||
webRequest.Timeout = _timeout * 1000;
|
||||
webRequest.ProtocolVersion = HttpVersion.Version10;
|
||||
if (fileLength > 0)
|
||||
{
|
||||
// 注意:设置远端请求文件的起始位置
|
||||
webRequest.AddRange(fileLength);
|
||||
// 注意:设置本地文件流的起始位置
|
||||
fileStream.Seek(fileLength, SeekOrigin.Begin);
|
||||
}
|
||||
|
||||
// 读取下载数据并保存到文件
|
||||
webResponse = webRequest.GetResponse() as HttpWebResponse;
|
||||
responseStream = webResponse.GetResponseStream();
|
||||
byte[] buffer = new byte[BufferSize];
|
||||
while (_running)
|
||||
{
|
||||
int length = responseStream.Read(buffer, 0, buffer.Length);
|
||||
if (length <= 0)
|
||||
break;
|
||||
|
||||
fileStream.Write(buffer, 0, length);
|
||||
|
||||
// 计算下载进度
|
||||
// 注意:原子操作保证数据安全
|
||||
fileLength += length;
|
||||
float progress = fileLength / fileTotalSize;
|
||||
DownloadProgress = progress;
|
||||
DownloadedBytes = (ulong)fileLength;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Error = e.Message;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (responseStream != null)
|
||||
{
|
||||
responseStream.Close();
|
||||
responseStream.Dispose();
|
||||
}
|
||||
|
||||
if (webResponse != null)
|
||||
{
|
||||
webResponse.Close();
|
||||
webResponse.Dispose();
|
||||
}
|
||||
|
||||
if (fileStream != null)
|
||||
{
|
||||
fileStream.Flush();
|
||||
fileStream.Close();
|
||||
}
|
||||
|
||||
IsDone = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private ThreadDownloader _threadDownloader;
|
||||
private float _tryAgainTimer;
|
||||
|
||||
public HttpDownloader(BundleInfo bundleInfo) : base(bundleInfo)
|
||||
{
|
||||
}
|
||||
public override void Update()
|
||||
{
|
||||
if (_steps == ESteps.None)
|
||||
return;
|
||||
if (IsDone())
|
||||
return;
|
||||
|
||||
// 检测本地文件
|
||||
if (_steps == ESteps.CheckLocalFile)
|
||||
{
|
||||
var verifyResult = CacheSystem.VerifyAndCacheBundle(_bundleInfo.Bundle, EVerifyLevel.High);
|
||||
if (verifyResult == EVerifyResult.Succeed)
|
||||
{
|
||||
_steps = ESteps.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (verifyResult == EVerifyResult.FileOverflow)
|
||||
{
|
||||
string cacheFilePath = _bundleInfo.Bundle.CachedFilePath;
|
||||
if (File.Exists(cacheFilePath))
|
||||
File.Delete(cacheFilePath);
|
||||
}
|
||||
_steps = ESteps.CreateDownload;
|
||||
}
|
||||
}
|
||||
|
||||
// 创建下载器
|
||||
if (_steps == ESteps.CreateDownload)
|
||||
{
|
||||
// 重置变量
|
||||
_downloadProgress = 0f;
|
||||
_downloadedBytes = 0;
|
||||
_tryAgainTimer = 0f;
|
||||
|
||||
_requestURL = GetRequestURL();
|
||||
_threadDownloader = new ThreadDownloader();
|
||||
_threadDownloader.Run(_requestURL, _bundleInfo.Bundle.CachedFilePath, _bundleInfo.Bundle.FileSize, _timeout);
|
||||
_steps = ESteps.CheckDownload;
|
||||
}
|
||||
|
||||
// 检测下载结果
|
||||
if (_steps == ESteps.CheckDownload)
|
||||
{
|
||||
_downloadProgress = _threadDownloader.DownloadProgress;
|
||||
_downloadedBytes = _threadDownloader.DownloadedBytes;
|
||||
if (_threadDownloader.IsDone == false)
|
||||
return;
|
||||
|
||||
bool hasError = false;
|
||||
|
||||
// 检查下载错误
|
||||
if (_threadDownloader.HasError())
|
||||
{
|
||||
hasError = true;
|
||||
_lastError = _threadDownloader.Error;
|
||||
}
|
||||
|
||||
// 检查文件完整性
|
||||
if (hasError == false)
|
||||
{
|
||||
var verifyResult = CacheSystem.VerifyAndCacheBundle(_bundleInfo.Bundle, EVerifyLevel.High);
|
||||
if (verifyResult != EVerifyResult.Succeed)
|
||||
{
|
||||
hasError = true;
|
||||
_lastError = $"Verify bundle content failed : {_bundleInfo.Bundle.FileName}";
|
||||
|
||||
// 验证失败后删除文件
|
||||
string cacheFilePath = _bundleInfo.Bundle.CachedFilePath;
|
||||
if (File.Exists(cacheFilePath))
|
||||
File.Delete(cacheFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果下载失败
|
||||
if (hasError)
|
||||
{
|
||||
// 失败后重新尝试
|
||||
if (_failedTryAgain > 0)
|
||||
{
|
||||
ReportWarning();
|
||||
_steps = ESteps.TryAgain;
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError();
|
||||
_steps = ESteps.Failed;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_lastError = string.Empty;
|
||||
_steps = ESteps.Succeed;
|
||||
}
|
||||
}
|
||||
|
||||
// 重新尝试下载
|
||||
if (_steps == ESteps.TryAgain)
|
||||
{
|
||||
_tryAgainTimer += UnityEngine.Time.unscaledDeltaTime;
|
||||
if (_tryAgainTimer > 1f)
|
||||
{
|
||||
_failedTryAgain--;
|
||||
_steps = ESteps.CreateDownload;
|
||||
YooLogger.Warning($"Try again download : {_requestURL}");
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void Abort()
|
||||
{
|
||||
if (IsDone() == false)
|
||||
{
|
||||
_steps = ESteps.Failed;
|
||||
_lastError = "user abort";
|
||||
if (_threadDownloader != null)
|
||||
{
|
||||
_threadDownloader.Abort();
|
||||
_threadDownloader = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
@@ -9,7 +8,6 @@ namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 编辑器下的模拟模式
|
||||
/// 注意:在初始化的时候自动构建真机模拟环境。
|
||||
/// </summary>
|
||||
EditorSimulateMode,
|
||||
|
||||
@@ -35,11 +33,6 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public bool LocationToLower = false;
|
||||
|
||||
/// <summary>
|
||||
/// 资源定位服务接口
|
||||
/// </summary>
|
||||
public ILocationServices LocationServices = null;
|
||||
|
||||
/// <summary>
|
||||
/// 文件解密服务接口
|
||||
/// </summary>
|
||||
|
||||
@@ -81,6 +81,14 @@ namespace YooAsset
|
||||
_taskCompletionSource.TrySetResult(null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空完成回调
|
||||
/// </summary>
|
||||
protected void ClearCompletedCallback()
|
||||
{
|
||||
_callback = null;
|
||||
}
|
||||
|
||||
#region 异步编程相关
|
||||
bool IEnumerator.MoveNext()
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
public class GameAsyncOperation : AsyncOperationBase
|
||||
public abstract class GameAsyncOperation : AsyncOperationBase
|
||||
{
|
||||
internal override void Start()
|
||||
{
|
||||
@@ -12,7 +12,22 @@ namespace YooAsset
|
||||
OnUpdate();
|
||||
}
|
||||
|
||||
protected virtual void OnStart() { }
|
||||
protected virtual void OnUpdate() { }
|
||||
/// <summary>
|
||||
/// 异步操作开始
|
||||
/// </summary>
|
||||
protected abstract void OnStart();
|
||||
|
||||
/// <summary>
|
||||
/// 异步操作更新
|
||||
/// </summary>
|
||||
protected abstract void OnUpdate();
|
||||
|
||||
/// <summary>
|
||||
/// 异步操作系统是否繁忙
|
||||
/// </summary>
|
||||
protected bool IsBusy()
|
||||
{
|
||||
return OperationSystem.IsBusy;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 清理未使用的缓存资源操作类
|
||||
/// </summary>
|
||||
public sealed class ClearUnusedCacheFilesOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
GetUnusedCacheFiles,
|
||||
ClearUnusedCacheFiles,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly List<AssetsPackage> _packages;
|
||||
private ESteps _steps = ESteps.None;
|
||||
private List<string> _unusedCacheFilePaths;
|
||||
private int _unusedFileTotalCount = 0;
|
||||
|
||||
internal ClearUnusedCacheFilesOperation(List<AssetsPackage> packages)
|
||||
{
|
||||
_packages = packages;
|
||||
}
|
||||
internal override void Start()
|
||||
{
|
||||
_steps = ESteps.GetUnusedCacheFiles;
|
||||
}
|
||||
internal override void Update()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.GetUnusedCacheFiles)
|
||||
{
|
||||
_unusedCacheFilePaths = GetUnusedCacheFilePaths();
|
||||
_unusedFileTotalCount = _unusedCacheFilePaths.Count;
|
||||
YooLogger.Log($"Found unused cache file count : {_unusedFileTotalCount}");
|
||||
_steps = ESteps.ClearUnusedCacheFiles;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.ClearUnusedCacheFiles)
|
||||
{
|
||||
for (int i = _unusedCacheFilePaths.Count - 1; i >= 0; i--)
|
||||
{
|
||||
string filePath = _unusedCacheFilePaths[i];
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(filePath);
|
||||
YooLogger.Log($"Delete unused cache file : {filePath}");
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
YooLogger.Warning($"Failed delete cache file : {filePath} Exception : {e}");
|
||||
}
|
||||
}
|
||||
_unusedCacheFilePaths.RemoveAt(i);
|
||||
|
||||
if (OperationSystem.IsBusy)
|
||||
break;
|
||||
}
|
||||
|
||||
if (_unusedFileTotalCount == 0)
|
||||
Progress = 1.0f;
|
||||
else
|
||||
Progress = 1.0f - (_unusedCacheFilePaths.Count / _unusedFileTotalCount);
|
||||
|
||||
if (_unusedCacheFilePaths.Count == 0)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取未被使用的缓存文件路径集合
|
||||
/// </summary>
|
||||
private List<string> GetUnusedCacheFilePaths()
|
||||
{
|
||||
string cacheFolderPath = SandboxHelper.GetCacheFolderPath();
|
||||
if (Directory.Exists(cacheFolderPath) == false)
|
||||
return new List<string>();
|
||||
|
||||
// 获取所有缓存文件
|
||||
DirectoryInfo directoryInfo = new DirectoryInfo(cacheFolderPath);
|
||||
FileInfo[] fileInfos = directoryInfo.GetFiles();
|
||||
List<string> result = new List<string>(fileInfos.Length);
|
||||
foreach (FileInfo fileInfo in fileInfos)
|
||||
{
|
||||
bool used = false;
|
||||
foreach (var package in _packages)
|
||||
{
|
||||
if (package.IsIncludeBundleFile(fileInfo.Name))
|
||||
{
|
||||
used = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (used == false)
|
||||
result.Add(fileInfo.FullName);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d188c50fd00bf941b2eeebb374dc0d1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -22,6 +22,7 @@ namespace YooAsset
|
||||
|
||||
private readonly int _downloadingMaxNumber;
|
||||
private readonly int _failedTryAgain;
|
||||
private readonly int _timeout;
|
||||
private readonly List<BundleInfo> _downloadList;
|
||||
private readonly List<DownloaderBase> _downloaders = new List<DownloaderBase>(MAX_LOADER_COUNT);
|
||||
private readonly List<DownloaderBase> _removeList = new List<DownloaderBase>(MAX_LOADER_COUNT);
|
||||
@@ -75,11 +76,12 @@ namespace YooAsset
|
||||
public OnStartDownloadFile OnStartDownloadFileCallback { set; get; }
|
||||
|
||||
|
||||
internal DownloaderOperation(List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain)
|
||||
internal DownloaderOperation(List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
_downloadList = downloadList;
|
||||
_downloadingMaxNumber = UnityEngine.Mathf.Clamp(downloadingMaxNumber, 1, MAX_LOADER_COUNT); ;
|
||||
_failedTryAgain = failedTryAgain;
|
||||
_timeout = timeout;
|
||||
|
||||
if (downloadList != null)
|
||||
{
|
||||
@@ -167,7 +169,7 @@ namespace YooAsset
|
||||
{
|
||||
int index = _downloadList.Count - 1;
|
||||
var bundleInfo = _downloadList[index];
|
||||
var operation = DownloadSystem.BeginDownload(bundleInfo, _failedTryAgain);
|
||||
var operation = DownloadSystem.BeginDownload(bundleInfo, _failedTryAgain, _timeout);
|
||||
_downloaders.Add(operation);
|
||||
_downloadList.RemoveAt(index);
|
||||
OnStartDownloadFileCallback?.Invoke(bundleInfo.Bundle.BundleName, bundleInfo.Bundle.FileSize);
|
||||
@@ -228,22 +230,22 @@ namespace YooAsset
|
||||
|
||||
public sealed class PackageDownloaderOperation : DownloaderOperation
|
||||
{
|
||||
internal PackageDownloaderOperation(List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain)
|
||||
: base(downloadList, downloadingMaxNumber, failedTryAgain)
|
||||
internal PackageDownloaderOperation(List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
: base(downloadList, downloadingMaxNumber, failedTryAgain, timeout)
|
||||
{
|
||||
}
|
||||
}
|
||||
public sealed class PatchDownloaderOperation : DownloaderOperation
|
||||
{
|
||||
internal PatchDownloaderOperation(List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain)
|
||||
: base(downloadList, downloadingMaxNumber, failedTryAgain)
|
||||
internal PatchDownloaderOperation(List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
: base(downloadList, downloadingMaxNumber, failedTryAgain, timeout)
|
||||
{
|
||||
}
|
||||
}
|
||||
public sealed class PatchUnpackerOperation : DownloaderOperation
|
||||
{
|
||||
internal PatchUnpackerOperation(List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain)
|
||||
: base(downloadList, downloadingMaxNumber, failedTryAgain)
|
||||
internal PatchUnpackerOperation(List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
: base(downloadList, downloadingMaxNumber, failedTryAgain, timeout)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,29 +67,39 @@ namespace YooAsset
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
Update,
|
||||
LoadAppManifest,
|
||||
InitVerifyingCache,
|
||||
UpdateVerifyingCache,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly OfflinePlayModeImpl _impl;
|
||||
private AppManifestLoader _appManifestLoader;
|
||||
private readonly AppManifestLoader _appManifestLoader;
|
||||
private readonly CacheVerifier _patchCacheVerifier;
|
||||
private ESteps _steps = ESteps.None;
|
||||
private float _verifyTime;
|
||||
|
||||
internal OfflinePlayModeInitializationOperation(OfflinePlayModeImpl impl, string buildinPackageName)
|
||||
{
|
||||
_impl = impl;
|
||||
_appManifestLoader = new AppManifestLoader(buildinPackageName);
|
||||
|
||||
#if UNITY_WEBGL
|
||||
_patchCacheVerifier = new CacheVerifierWithoutThread();
|
||||
#else
|
||||
_patchCacheVerifier = new CacheVerifierWithThread();
|
||||
#endif
|
||||
}
|
||||
internal override void Start()
|
||||
{
|
||||
_steps = ESteps.Update;
|
||||
_steps = ESteps.LoadAppManifest;
|
||||
}
|
||||
internal override void Update()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.Update)
|
||||
if (_steps == ESteps.LoadAppManifest)
|
||||
{
|
||||
_appManifestLoader.Update();
|
||||
Progress = _appManifestLoader.Progress();
|
||||
@@ -103,10 +113,29 @@ namespace YooAsset
|
||||
Error = _appManifestLoader.Error;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.InitVerifyingCache;
|
||||
_impl.SetAppPatchManifest(_appManifestLoader.Result);
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.InitVerifyingCache)
|
||||
{
|
||||
var verifyInfos = _impl.GetVerifyInfoList();
|
||||
_patchCacheVerifier.InitVerifier(verifyInfos);
|
||||
_verifyTime = UnityEngine.Time.realtimeSinceStartup;
|
||||
_steps = ESteps.UpdateVerifyingCache;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.UpdateVerifyingCache)
|
||||
{
|
||||
Progress = _patchCacheVerifier.GetVerifierProgress();
|
||||
if (_patchCacheVerifier.UpdateVerifier())
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
_impl.SetAppPatchManifest(_appManifestLoader.Result);
|
||||
float costTime = UnityEngine.Time.realtimeSinceStartup - _verifyTime;
|
||||
YooLogger.Log($"Verify result : Success {_patchCacheVerifier.VerifySuccessList.Count}, Fail {_patchCacheVerifier.VerifyFailList.Count}, Elapsed time {costTime} seconds");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,9 +65,9 @@ namespace YooAsset
|
||||
private readonly string _packageName;
|
||||
private readonly string _packageCRC;
|
||||
private readonly int _timeout;
|
||||
private ESteps _steps = ESteps.None;
|
||||
private UnityWebDataRequester _downloader;
|
||||
private PatchCacheVerifier _patchCacheVerifier;
|
||||
private CacheVerifier _cacheVerifier;
|
||||
private ESteps _steps = ESteps.None;
|
||||
private float _verifyTime;
|
||||
|
||||
internal HostPlayModeUpdateManifestOperation(HostPlayModeImpl impl, string packageName, string packageCRC, int timeout)
|
||||
@@ -78,9 +78,9 @@ namespace YooAsset
|
||||
_timeout = timeout;
|
||||
|
||||
#if UNITY_WEBGL
|
||||
_patchCacheVerifier = new PatchCacheVerifierWithoutThread();
|
||||
_cacheVerifier = new CacheVerifierWithoutThread();
|
||||
#else
|
||||
_patchCacheVerifier = new PatchCacheVerifierWithThread();
|
||||
_cacheVerifier = new CacheVerifierWithThread();
|
||||
#endif
|
||||
}
|
||||
internal override void Start()
|
||||
@@ -154,20 +154,21 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.InitVerifyingCache)
|
||||
{
|
||||
_patchCacheVerifier.InitVerifier(_impl, false);
|
||||
var verifyInfos = _impl.GetVerifyInfoList(false);
|
||||
_cacheVerifier.InitVerifier(verifyInfos);
|
||||
_verifyTime = UnityEngine.Time.realtimeSinceStartup;
|
||||
_steps = ESteps.UpdateVerifyingCache;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.UpdateVerifyingCache)
|
||||
{
|
||||
Progress = _patchCacheVerifier.GetVerifierProgress();
|
||||
if (_patchCacheVerifier.UpdateVerifier())
|
||||
Progress = _cacheVerifier.GetVerifierProgress();
|
||||
if (_cacheVerifier.UpdateVerifier())
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
float costTime = UnityEngine.Time.realtimeSinceStartup - _verifyTime;
|
||||
YooLogger.Log($"Verify result : Success {_patchCacheVerifier.VerifySuccessCount}, Fail {_patchCacheVerifier.VerifyFailCount}, Elapsed time {costTime} seconds");
|
||||
YooLogger.Log($"Verify result : Success {_cacheVerifier.VerifySuccessList.Count}, Fail {_cacheVerifier.VerifyFailList.Count}, Elapsed time {costTime} seconds");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -254,7 +255,7 @@ namespace YooAsset
|
||||
private readonly string _packageName;
|
||||
private readonly string _packageCRC;
|
||||
private ESteps _steps = ESteps.None;
|
||||
private PatchCacheVerifier _patchCacheVerifier;
|
||||
private CacheVerifier _cacheVerifier;
|
||||
private float _verifyTime;
|
||||
|
||||
internal HostPlayModeWeaklyUpdateManifestOperation(HostPlayModeImpl impl, string packageName, string packageCRC)
|
||||
@@ -264,9 +265,9 @@ namespace YooAsset
|
||||
_packageCRC = packageCRC;
|
||||
|
||||
#if UNITY_WEBGL
|
||||
_patchCacheVerifier = new PatchCacheVerifierWithoutThread();
|
||||
_cacheVerifier = new CacheVerifierWithoutThread();
|
||||
#else
|
||||
_patchCacheVerifier = new PatchCacheVerifierWithThread();
|
||||
_cacheVerifier = new CacheVerifierWithThread();
|
||||
#endif
|
||||
}
|
||||
internal override void Start()
|
||||
@@ -286,36 +287,41 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.InitVerifyingCache)
|
||||
{
|
||||
if (_patchCacheVerifier.InitVerifier(_impl, true))
|
||||
{
|
||||
_verifyTime = UnityEngine.Time.realtimeSinceStartup;
|
||||
_steps = ESteps.UpdateVerifyingCache;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"The package resource {_packageName}_{_packageCRC} content is not complete !";
|
||||
}
|
||||
var verifyInfos = _impl.GetVerifyInfoList(true);
|
||||
_cacheVerifier.InitVerifier(verifyInfos);
|
||||
_verifyTime = UnityEngine.Time.realtimeSinceStartup;
|
||||
_steps = ESteps.UpdateVerifyingCache;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.UpdateVerifyingCache)
|
||||
{
|
||||
Progress = _patchCacheVerifier.GetVerifierProgress();
|
||||
if (_patchCacheVerifier.UpdateVerifier())
|
||||
Progress = _cacheVerifier.GetVerifierProgress();
|
||||
if (_cacheVerifier.UpdateVerifier())
|
||||
{
|
||||
float costTime = UnityEngine.Time.realtimeSinceStartup - _verifyTime;
|
||||
YooLogger.Log($"Verify result : Success {_patchCacheVerifier.VerifySuccessCount}, Fail {_patchCacheVerifier.VerifyFailCount}, Elapsed time {costTime} seconds");
|
||||
if (_patchCacheVerifier.VerifyFailCount > 0)
|
||||
YooLogger.Log($"Verify result : Success {_cacheVerifier.VerifySuccessList.Count}, Fail {_cacheVerifier.VerifyFailList.Count}, Elapsed time {costTime} seconds");
|
||||
|
||||
bool verifySucceed = true;
|
||||
foreach (var verifyInfo in _cacheVerifier.VerifyFailList)
|
||||
{
|
||||
// 注意:跳过内置资源文件
|
||||
if (verifyInfo.IsBuildinFile)
|
||||
continue;
|
||||
|
||||
verifySucceed = false;
|
||||
YooLogger.Warning($"Failed verify file : {verifyInfo.VerifyFilePath}");
|
||||
}
|
||||
|
||||
if (verifySucceed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"The package resource {_packageName}_{_packageCRC} content has verify failed file !";
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"The package resource {_packageName}_{_packageCRC} content has verify failed file !";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
public abstract PackageDownloaderOperation CreatePackageDownloader(int downloadingMaxNumber, int failedTryAgain);
|
||||
/// <param name="timeout">超时时间(单位:秒)</param>
|
||||
public abstract PackageDownloaderOperation CreatePackageDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -31,10 +32,10 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 创建包裹下载器
|
||||
/// </summary>
|
||||
public override PackageDownloaderOperation CreatePackageDownloader(int downloadingMaxNumber, int failedTryAgain)
|
||||
public override PackageDownloaderOperation CreatePackageDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||
var operation = new PackageDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
||||
var operation = new PackageDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
}
|
||||
@@ -55,10 +56,10 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 创建包裹下载器
|
||||
/// </summary>
|
||||
public override PackageDownloaderOperation CreatePackageDownloader(int downloadingMaxNumber, int failedTryAgain)
|
||||
public override PackageDownloaderOperation CreatePackageDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||
var operation = new PackageDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
||||
var operation = new PackageDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
}
|
||||
@@ -147,18 +148,18 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 创建包裹下载器
|
||||
/// </summary>
|
||||
public override PackageDownloaderOperation CreatePackageDownloader(int downloadingMaxNumber, int failedTryAgain)
|
||||
public override PackageDownloaderOperation CreatePackageDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
if (Status == EOperationStatus.Succeed)
|
||||
{
|
||||
List<BundleInfo> downloadList = GetDownloadList();
|
||||
var operation = new PackageDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain);
|
||||
var operation = new PackageDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Error($"{nameof(UpdatePackageOperation)} status is failed !");
|
||||
var operation = new PackageDownloaderOperation(null, downloadingMaxNumber, failedTryAgain);
|
||||
var operation = new PackageDownloaderOperation(null, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,11 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public string PackageName;
|
||||
|
||||
/// <summary>
|
||||
/// 人类可读的版本信息
|
||||
/// </summary>
|
||||
public string HumanReadableVersion;
|
||||
|
||||
/// <summary>
|
||||
/// 资源列表(主动收集的资源列表)
|
||||
/// </summary>
|
||||
@@ -142,6 +147,23 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 尝试映射为资源路径
|
||||
/// </summary>
|
||||
public string TryMappingToAssetPath(string location)
|
||||
{
|
||||
if (string.IsNullOrEmpty(location))
|
||||
return string.Empty;
|
||||
|
||||
if (_locationToLower)
|
||||
location = location.ToLower();
|
||||
|
||||
if (AssetPathMapping.TryGetValue(location, out string assetPath))
|
||||
return assetPath;
|
||||
else
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取主资源包
|
||||
/// 注意:传入的资源路径一定合法有效!
|
||||
@@ -212,6 +234,19 @@ namespace YooAsset
|
||||
return BundleDic.TryGetValue(bundleName, out result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否包含资源文件
|
||||
/// </summary>
|
||||
public bool IsIncludeBundleFile(string fileName)
|
||||
{
|
||||
foreach (var patchBundle in BundleList)
|
||||
{
|
||||
if (patchBundle.FileName == fileName)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 序列化
|
||||
|
||||
@@ -10,12 +10,12 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 编辑器下模拟构建补丁清单
|
||||
/// </summary>
|
||||
public static string SimulateBuild(string packageName, bool enableAddressable)
|
||||
public static string SimulateBuild(string packageName)
|
||||
{
|
||||
if (_classType == null)
|
||||
_classType = Assembly.Load("YooAsset.Editor").GetType("YooAsset.Editor.AssetBundleSimulateBuilder");
|
||||
|
||||
string manifestFilePath = (string)InvokePublicStaticMethod(_classType, "SimulateBuild", packageName, enableAddressable);
|
||||
string manifestFilePath = (string)InvokePublicStaticMethod(_classType, "SimulateBuild", packageName);
|
||||
return manifestFilePath;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 编辑器下模拟构建补丁清单
|
||||
/// </summary>
|
||||
public static string SimulateBuild(string packageName, bool enableAddressable) { throw new System.Exception("Only support in unity editor !"); }
|
||||
public static string SimulateBuild(string packageName) { throw new System.Exception("Only support in unity editor !"); }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -20,7 +20,16 @@ namespace YooAsset
|
||||
return operation;
|
||||
}
|
||||
|
||||
// 设置资源清单
|
||||
/// <summary>
|
||||
/// 获取人类可读的版本信息
|
||||
/// </summary>
|
||||
public string GetHumanReadableVersion()
|
||||
{
|
||||
if (_simulatePatchManifest == null)
|
||||
return string.Empty;
|
||||
return _simulatePatchManifest.HumanReadableVersion;
|
||||
}
|
||||
|
||||
internal void SetSimulatePatchManifest(PatchManifest patchManifest)
|
||||
{
|
||||
_simulatePatchManifest = patchManifest;
|
||||
@@ -57,10 +66,18 @@ namespace YooAsset
|
||||
{
|
||||
return _simulatePatchManifest.MappingToAssetPath(location);
|
||||
}
|
||||
string IBundleServices.TryMappingToAssetPath(string location)
|
||||
{
|
||||
return _simulatePatchManifest.TryMappingToAssetPath(location);
|
||||
}
|
||||
string IBundleServices.GetPackageName()
|
||||
{
|
||||
return _simulatePatchManifest.PackageName;
|
||||
}
|
||||
bool IBundleServices.IsIncludeBundleFile(string fileName)
|
||||
{
|
||||
return _simulatePatchManifest.IsIncludeBundleFile(fileName);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,16 @@ namespace YooAsset
|
||||
return operation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取人类可读的版本信息
|
||||
/// </summary>
|
||||
public string GetHumanReadableVersion()
|
||||
{
|
||||
if (LocalPatchManifest == null)
|
||||
return string.Empty;
|
||||
return LocalPatchManifest.HumanReadableVersion;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步更新资源版本号
|
||||
/// </summary>
|
||||
@@ -74,10 +84,10 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 创建下载器
|
||||
/// </summary>
|
||||
public PatchDownloaderOperation CreatePatchDownloaderByAll(int fileLoadingMaxNumber, int failedTryAgain)
|
||||
public PatchDownloaderOperation CreatePatchDownloaderByAll(int fileLoadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = GetDownloadListByAll();
|
||||
var operation = new PatchDownloaderOperation(downloadList, fileLoadingMaxNumber, failedTryAgain);
|
||||
var operation = new PatchDownloaderOperation(downloadList, fileLoadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
private List<BundleInfo> GetDownloadListByAll()
|
||||
@@ -102,10 +112,10 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 创建下载器
|
||||
/// </summary>
|
||||
public PatchDownloaderOperation CreatePatchDownloaderByTags(string[] tags, int fileLoadingMaxNumber, int failedTryAgain)
|
||||
public PatchDownloaderOperation CreatePatchDownloaderByTags(string[] tags, int fileLoadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = GetDownloadListByTags(tags);
|
||||
var operation = new PatchDownloaderOperation(downloadList, fileLoadingMaxNumber, failedTryAgain);
|
||||
var operation = new PatchDownloaderOperation(downloadList, fileLoadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
private List<BundleInfo> GetDownloadListByTags(string[] tags)
|
||||
@@ -142,10 +152,10 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 创建下载器
|
||||
/// </summary>
|
||||
public PatchDownloaderOperation CreatePatchDownloaderByPaths(AssetInfo[] assetInfos, int fileLoadingMaxNumber, int failedTryAgain)
|
||||
public PatchDownloaderOperation CreatePatchDownloaderByPaths(AssetInfo[] assetInfos, int fileLoadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = GetDownloadListByPaths(assetInfos);
|
||||
var operation = new PatchDownloaderOperation(downloadList, fileLoadingMaxNumber, failedTryAgain);
|
||||
var operation = new PatchDownloaderOperation(downloadList, fileLoadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
private List<BundleInfo> GetDownloadListByPaths(AssetInfo[] assetInfos)
|
||||
@@ -194,10 +204,10 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 创建解压器
|
||||
/// </summary>
|
||||
public PatchUnpackerOperation CreatePatchUnpackerByTags(string[] tags, int fileUpackingMaxNumber, int failedTryAgain)
|
||||
public PatchUnpackerOperation CreatePatchUnpackerByTags(string[] tags, int fileUpackingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> unpcakList = GetUnpackListByTags(tags);
|
||||
var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain);
|
||||
var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
private List<BundleInfo> GetUnpackListByTags(string[] tags)
|
||||
@@ -225,10 +235,10 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 创建解压器
|
||||
/// </summary>
|
||||
public PatchUnpackerOperation CreatePatchUnpackerByAll(int fileUpackingMaxNumber, int failedTryAgain)
|
||||
public PatchUnpackerOperation CreatePatchUnpackerByAll(int fileUpackingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> unpcakList = GetUnpackListByAll();
|
||||
var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain);
|
||||
var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
private List<BundleInfo> GetUnpackListByAll()
|
||||
@@ -278,6 +288,38 @@ namespace YooAsset
|
||||
return bundleInfo;
|
||||
}
|
||||
|
||||
internal List<VerifyInfo> GetVerifyInfoList(bool weaklyUpdateMode)
|
||||
{
|
||||
List<VerifyInfo> result = new List<VerifyInfo>(LocalPatchManifest.BundleList.Count);
|
||||
|
||||
// 遍历所有文件然后验证并缓存合法文件
|
||||
foreach (var patchBundle in LocalPatchManifest.BundleList)
|
||||
{
|
||||
// 忽略缓存文件
|
||||
if (CacheSystem.IsCached(patchBundle))
|
||||
continue;
|
||||
|
||||
// 注意:在弱联网模式下,我们需要验证指定资源版本的所有资源完整性
|
||||
if (weaklyUpdateMode)
|
||||
{
|
||||
bool isBuildinFile = IsBuildinPatchBundle(patchBundle);
|
||||
VerifyInfo verifyInfo = new VerifyInfo(isBuildinFile, patchBundle);
|
||||
result.Add(verifyInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
string filePath = patchBundle.CachedFilePath;
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
bool isBuildinFile = IsBuildinPatchBundle(patchBundle);
|
||||
VerifyInfo verifyInfo = new VerifyInfo(isBuildinFile, patchBundle);
|
||||
result.Add(verifyInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
internal void SetLocalPatchManifest(PatchManifest patchManifest)
|
||||
{
|
||||
LocalPatchManifest = patchManifest;
|
||||
@@ -350,10 +392,18 @@ namespace YooAsset
|
||||
{
|
||||
return LocalPatchManifest.MappingToAssetPath(location);
|
||||
}
|
||||
string IBundleServices.TryMappingToAssetPath(string location)
|
||||
{
|
||||
return LocalPatchManifest.TryMappingToAssetPath(location);
|
||||
}
|
||||
string IBundleServices.GetPackageName()
|
||||
{
|
||||
return LocalPatchManifest.PackageName;
|
||||
}
|
||||
bool IBundleServices.IsIncludeBundleFile(string fileName)
|
||||
{
|
||||
return LocalPatchManifest.IsIncludeBundleFile(fileName);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
@@ -20,7 +21,38 @@ namespace YooAsset
|
||||
return operation;
|
||||
}
|
||||
|
||||
// 设置资源清单
|
||||
/// <summary>
|
||||
/// 获取人类可读的版本信息
|
||||
/// </summary>
|
||||
public string GetHumanReadableVersion()
|
||||
{
|
||||
if (_appPatchManifest == null)
|
||||
return string.Empty;
|
||||
return _appPatchManifest.HumanReadableVersion;
|
||||
}
|
||||
|
||||
internal List<VerifyInfo> GetVerifyInfoList()
|
||||
{
|
||||
List<VerifyInfo> result = new List<VerifyInfo>(_appPatchManifest.BundleList.Count);
|
||||
|
||||
// 遍历所有文件然后验证并缓存合法文件
|
||||
foreach (var patchBundle in _appPatchManifest.BundleList)
|
||||
{
|
||||
// 忽略缓存文件
|
||||
if (CacheSystem.IsCached(patchBundle))
|
||||
continue;
|
||||
|
||||
string filePath = patchBundle.CachedFilePath;
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
bool isBuildinFile = true;
|
||||
VerifyInfo verifyInfo = new VerifyInfo(isBuildinFile, patchBundle);
|
||||
result.Add(verifyInfo);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
internal void SetAppPatchManifest(PatchManifest patchManifest)
|
||||
{
|
||||
_appPatchManifest = patchManifest;
|
||||
@@ -85,10 +117,18 @@ namespace YooAsset
|
||||
{
|
||||
return _appPatchManifest.MappingToAssetPath(location);
|
||||
}
|
||||
string IBundleServices.TryMappingToAssetPath(string location)
|
||||
{
|
||||
return _appPatchManifest.TryMappingToAssetPath(location);
|
||||
}
|
||||
string IBundleServices.GetPackageName()
|
||||
{
|
||||
return _appPatchManifest.PackageName;
|
||||
}
|
||||
bool IBundleServices.IsIncludeBundleFile(string fileName)
|
||||
{
|
||||
return _appPatchManifest.IsIncludeBundleFile(fileName);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -28,9 +28,19 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
string MappingToAssetPath(string location);
|
||||
|
||||
/// <summary>
|
||||
/// 尝试映射为资源路径
|
||||
/// </summary>
|
||||
string TryMappingToAssetPath(string location);
|
||||
|
||||
/// <summary>
|
||||
/// 获取所属的包裹名
|
||||
/// </summary>
|
||||
string GetPackageName();
|
||||
|
||||
/// <summary>
|
||||
/// 是否包含资源文件
|
||||
/// </summary>
|
||||
bool IsIncludeBundleFile(string fileName);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
public interface ILocationServices
|
||||
{
|
||||
/// <summary>
|
||||
/// 定位地址转换为资源路径
|
||||
/// </summary>
|
||||
string ConvertLocationToAssetPath(YooAssetPackage package, string location);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e400ee1e8b3556479bfa493ff7fe778
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,11 +0,0 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
public class AddressLocationServices : ILocationServices
|
||||
{
|
||||
string ILocationServices.ConvertLocationToAssetPath(YooAssetPackage package, string location)
|
||||
{
|
||||
return package.MappingToAssetPath(location);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
public class DefaultLocationServices : ILocationServices
|
||||
{
|
||||
private readonly string _resourceRoot;
|
||||
|
||||
public DefaultLocationServices(string resourceRoot)
|
||||
{
|
||||
if (string.IsNullOrEmpty(resourceRoot) == false)
|
||||
_resourceRoot = PathHelper.GetRegularPath(resourceRoot);
|
||||
}
|
||||
|
||||
string ILocationServices.ConvertLocationToAssetPath(YooAssetPackage package, string location)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_resourceRoot))
|
||||
{
|
||||
return package.MappingToAssetPath(location);
|
||||
}
|
||||
else
|
||||
{
|
||||
string tempLocation = $"{_resourceRoot}/{location}";
|
||||
return package.MappingToAssetPath(tempLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,12 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public const string UnityShadersBundleName = "unityshaders";
|
||||
|
||||
/// <summary>
|
||||
/// 内置资源目录名称
|
||||
/// </summary>
|
||||
public const string StreamingAssetsBuildinFolder = "BuildinFiles";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 忽略的文件类型
|
||||
/// </summary>
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public static string MakeStreamingLoadPath(string path)
|
||||
{
|
||||
return StringUtility.Format("{0}/YooAssets/{1}", UnityEngine.Application.streamingAssetsPath, path);
|
||||
return StringUtility.Format("{0}/{1}/{2}", UnityEngine.Application.streamingAssetsPath, YooAssetSettings.StreamingAssetsBuildinFolder, path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace YooAsset
|
||||
public static partial class YooAssets
|
||||
{
|
||||
private static bool _isInitialize = false;
|
||||
private static readonly List<YooAssetPackage> _packages = new List<YooAssetPackage>();
|
||||
private static readonly List<AssetsPackage> _packages = new List<AssetsPackage>();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化资源系统
|
||||
@@ -17,17 +17,18 @@ namespace YooAsset
|
||||
public static void Initialize()
|
||||
{
|
||||
if (_isInitialize)
|
||||
throw new Exception("YooAssets is initialized !");
|
||||
throw new Exception($"{nameof(YooAssets)} is initialized !");
|
||||
|
||||
// 创建驱动器
|
||||
if (_isInitialize == false)
|
||||
{
|
||||
// 创建驱动器
|
||||
_isInitialize = true;
|
||||
UnityEngine.GameObject driverGo = new UnityEngine.GameObject("[YooAsset]");
|
||||
driverGo.AddComponent<YooAssetDriver>();
|
||||
UnityEngine.GameObject driverGo = new UnityEngine.GameObject($"[{nameof(YooAssets)}]");
|
||||
driverGo.AddComponent<YooAssetsDriver>();
|
||||
UnityEngine.Object.DontDestroyOnLoad(driverGo);
|
||||
|
||||
#if DEBUG
|
||||
// 添加远程调试脚本
|
||||
driverGo.AddComponent<RemoteDebuggerInRuntime>();
|
||||
#endif
|
||||
|
||||
@@ -80,28 +81,53 @@ namespace YooAsset
|
||||
/// 创建资源包
|
||||
/// </summary>
|
||||
/// <param name="packageName">资源包名称</param>
|
||||
public static YooAssetPackage CreateAssetPackage(string packageName)
|
||||
public static AssetsPackage CreateAssetsPackage(string packageName)
|
||||
{
|
||||
if (_isInitialize == false)
|
||||
throw new Exception("YooAssets not initialize !");
|
||||
throw new Exception($"{nameof(YooAssets)} not initialize !");
|
||||
|
||||
if (string.IsNullOrEmpty(packageName))
|
||||
throw new Exception("PackageName is null or empty !");
|
||||
throw new Exception("Package name is null or empty !");
|
||||
|
||||
if (HasAssetPackage(packageName))
|
||||
if (HasAssetsPackage(packageName))
|
||||
throw new Exception($"Package {packageName} already existed !");
|
||||
|
||||
YooAssetPackage component = new YooAssetPackage(packageName);
|
||||
_packages.Add(component);
|
||||
return component;
|
||||
AssetsPackage assetsPackage = new AssetsPackage(packageName);
|
||||
_packages.Add(assetsPackage);
|
||||
return assetsPackage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包
|
||||
/// </summary>
|
||||
/// <param name="packageName">资源包名称</param>
|
||||
public static AssetsPackage GetAssetsPackage(string packageName)
|
||||
{
|
||||
if (_isInitialize == false)
|
||||
throw new Exception($"{nameof(YooAssets)} not initialize !");
|
||||
|
||||
if (string.IsNullOrEmpty(packageName))
|
||||
throw new Exception("Package name is null or empty !");
|
||||
|
||||
foreach (var package in _packages)
|
||||
{
|
||||
if (package.PackageName == packageName)
|
||||
return package;
|
||||
}
|
||||
|
||||
YooLogger.Warning($"Not found assets package : {packageName}");
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测资源包是否存在
|
||||
/// </summary>
|
||||
/// <param name="packageName">资源包名称</param>
|
||||
public static bool HasAssetPackage(string packageName)
|
||||
public static bool HasAssetsPackage(string packageName)
|
||||
{
|
||||
if (_isInitialize == false)
|
||||
throw new Exception($"{nameof(YooAssets)} not initialize !");
|
||||
|
||||
foreach (var package in _packages)
|
||||
{
|
||||
if (package.PackageName == packageName)
|
||||
@@ -109,7 +135,7 @@ namespace YooAsset
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 开启一个异步操作
|
||||
/// </summary>
|
||||
@@ -121,7 +147,7 @@ namespace YooAsset
|
||||
|
||||
#region 系统参数
|
||||
/// <summary>
|
||||
/// 启用下载系统的断点续传功能的文件大小
|
||||
/// 设置下载系统参数,启用断点续传功能文件的最小字节数
|
||||
/// </summary>
|
||||
public static void SetDownloadSystemBreakpointResumeFileSize(int fileBytes)
|
||||
{
|
||||
@@ -129,7 +155,23 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置异步系统的每帧允许运行的最大时间切片(单位:毫秒)
|
||||
/// 设置下载系统参数,下载失败后清理文件的HTTP错误码
|
||||
/// </summary>
|
||||
public static void SetDownloadSystemClearFileResponseCode(List<long> codes)
|
||||
{
|
||||
DownloadSystem.ClearFileResponseCodes = codes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置下载系统参数,自定义的证书认证实例
|
||||
/// </summary>
|
||||
public static void SetDownloadSystemCertificateHandler(UnityEngine.Networking.CertificateHandler instance)
|
||||
{
|
||||
DownloadSystem.CertificateHandlerInstance = instance;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置异步系统参数,每帧执行消耗的最大时间切片(单位:毫秒)
|
||||
/// </summary>
|
||||
public static void SetOperationSystemMaxTimeSlice(long milliseconds)
|
||||
{
|
||||
@@ -142,7 +184,7 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置缓存系统的已经缓存文件的校验等级
|
||||
/// 设置缓存系统参数,已经缓存文件的校验等级
|
||||
/// </summary>
|
||||
public static void SetCacheSystemCachedFileVerifyLevel(EVerifyLevel verifyLevel)
|
||||
{
|
||||
@@ -151,6 +193,24 @@ namespace YooAsset
|
||||
#endregion
|
||||
|
||||
#region 沙盒相关
|
||||
/// <summary>
|
||||
/// 清理未使用的缓存文件
|
||||
/// </summary>
|
||||
public static ClearUnusedCacheFilesOperation ClearUnusedCacheFiles()
|
||||
{
|
||||
ClearUnusedCacheFilesOperation operation = new ClearUnusedCacheFilesOperation(_packages);
|
||||
OperationSystem.StartOperation(operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取内置文件夹名称
|
||||
/// </summary>
|
||||
public static string GetStreamingAssetBuildinFolderName()
|
||||
{
|
||||
return YooAssetSettings.StreamingAssetsBuildinFolder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取沙盒的根路径
|
||||
/// </summary>
|
||||
@@ -166,14 +226,6 @@ namespace YooAsset
|
||||
{
|
||||
SandboxHelper.DeleteSandbox();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空所有的缓存文件
|
||||
/// </summary>
|
||||
public static void ClearAllCacheFiles()
|
||||
{
|
||||
SandboxHelper.DeleteCacheFolder();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 调试信息
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class YooAssetDriver : MonoBehaviour
|
||||
internal class YooAssetsDriver : MonoBehaviour
|
||||
{
|
||||
void Update()
|
||||
{
|
||||
@@ -8,74 +8,16 @@ namespace YooAsset
|
||||
{
|
||||
public static partial class YooAssets
|
||||
{
|
||||
private static YooAssetPackage _mainPackage;
|
||||
private static AssetsPackage _defaultPackage;
|
||||
|
||||
/// <summary>
|
||||
/// 是否已经初始化
|
||||
/// 设置默认的资源包
|
||||
/// </summary>
|
||||
public static bool IsInitialized
|
||||
public static void SetDefaultAssetsPackage(AssetsPackage assetsPackage)
|
||||
{
|
||||
get { return _mainPackage.IsInitialized; }
|
||||
_defaultPackage = assetsPackage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步初始化
|
||||
/// </summary>
|
||||
public static InitializationOperation InitializeAsync(InitializeParameters parameters, string packageName = "DefaultPackage")
|
||||
{
|
||||
if (_mainPackage != null)
|
||||
throw new Exception("Main package is initialized yet.");
|
||||
|
||||
_mainPackage = CreateAssetPackage(packageName);
|
||||
return _mainPackage.InitializeAsync(parameters);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 向网络端请求静态资源版本
|
||||
/// </summary>
|
||||
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
||||
public static UpdateStaticVersionOperation UpdateStaticVersionAsync(int timeout = 60)
|
||||
{
|
||||
return _mainPackage.UpdateStaticVersionAsync(timeout);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 向网络端请求并更新补丁清单
|
||||
/// </summary>
|
||||
/// <param name="packageCRC">更新的资源包裹版本</param>
|
||||
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
||||
public static UpdateManifestOperation UpdateManifestAsync(string packageCRC, int timeout = 60)
|
||||
{
|
||||
return _mainPackage.UpdateManifestAsync(packageCRC, timeout);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 弱联网情况下加载补丁清单
|
||||
/// 注意:当指定版本内容验证失败后会返回失败。
|
||||
/// </summary>
|
||||
/// <param name="packageCRC">指定的资源包裹版本</param>
|
||||
public static UpdateManifestOperation WeaklyUpdateManifestAsync(string packageCRC)
|
||||
{
|
||||
return _mainPackage.WeaklyUpdateManifestAsync(packageCRC);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源回收(卸载引用计数为零的资源)
|
||||
/// </summary>
|
||||
public static void UnloadUnusedAssets()
|
||||
{
|
||||
_mainPackage.UnloadUnusedAssets();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 强制回收所有资源
|
||||
/// </summary>
|
||||
public static void ForceUnloadAllAssets()
|
||||
{
|
||||
_mainPackage.ForceUnloadAllAssets();
|
||||
}
|
||||
|
||||
|
||||
#region 资源信息
|
||||
/// <summary>
|
||||
/// 是否需要从远端更新下载
|
||||
@@ -83,7 +25,8 @@ namespace YooAsset
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static bool IsNeedDownloadFromRemote(string location)
|
||||
{
|
||||
return _mainPackage.IsNeedDownloadFromRemote(location);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.IsNeedDownloadFromRemote(location);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -92,7 +35,8 @@ namespace YooAsset
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static bool IsNeedDownloadFromRemote(AssetInfo assetInfo)
|
||||
{
|
||||
return _mainPackage.IsNeedDownloadFromRemote(assetInfo);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.IsNeedDownloadFromRemote(assetInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -101,7 +45,8 @@ namespace YooAsset
|
||||
/// <param name="tag">资源标签</param>
|
||||
public static AssetInfo[] GetAssetInfos(string tag)
|
||||
{
|
||||
return _mainPackage.GetAssetInfos(tag);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.GetAssetInfos(tag);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -110,7 +55,8 @@ namespace YooAsset
|
||||
/// <param name="tags">资源标签列表</param>
|
||||
public static AssetInfo[] GetAssetInfos(string[] tags)
|
||||
{
|
||||
return _mainPackage.GetAssetInfos(tags);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.GetAssetInfos(tags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -119,17 +65,18 @@ namespace YooAsset
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static AssetInfo GetAssetInfo(string location)
|
||||
{
|
||||
return _mainPackage.GetAssetInfo(location);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.GetAssetInfo(location);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源路径
|
||||
/// 检查资源定位地址是否有效
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
/// <returns>如果location地址无效,则返回空字符串</returns>
|
||||
public static string GetAssetPath(string location)
|
||||
public static bool CheckLocationValid(string location)
|
||||
{
|
||||
return _mainPackage.GetAssetPath(location);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.CheckLocationValid(location);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -141,7 +88,8 @@ namespace YooAsset
|
||||
/// <param name="copyPath">拷贝路径</param>
|
||||
public static RawFileOperation GetRawFileAsync(string location, string copyPath = null)
|
||||
{
|
||||
return _mainPackage.GetRawFileAsync(location, copyPath);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.GetRawFileAsync(location, copyPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -151,7 +99,8 @@ namespace YooAsset
|
||||
/// <param name="copyPath">拷贝路径</param>
|
||||
public static RawFileOperation GetRawFileAsync(AssetInfo assetInfo, string copyPath = null)
|
||||
{
|
||||
return _mainPackage.GetRawFileAsync(assetInfo, copyPath);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.GetRawFileAsync(assetInfo, copyPath);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -165,7 +114,8 @@ namespace YooAsset
|
||||
/// <param name="priority">优先级</param>
|
||||
public static SceneOperationHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
|
||||
{
|
||||
return _mainPackage.LoadSceneAsync(location, sceneMode, activateOnLoad, priority);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadSceneAsync(location, sceneMode, activateOnLoad, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -177,7 +127,8 @@ namespace YooAsset
|
||||
/// <param name="priority">优先级</param>
|
||||
public static SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
|
||||
{
|
||||
return _mainPackage.LoadSceneAsync(assetInfo, sceneMode, activateOnLoad, priority);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadSceneAsync(assetInfo, sceneMode, activateOnLoad, priority);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -188,7 +139,8 @@ namespace YooAsset
|
||||
/// <param name="assetInfo">资源信息</param>
|
||||
public static AssetOperationHandle LoadAssetSync(AssetInfo assetInfo)
|
||||
{
|
||||
return _mainPackage.LoadAssetSync(assetInfo);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAssetSync(assetInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -198,7 +150,8 @@ namespace YooAsset
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static AssetOperationHandle LoadAssetSync<TObject>(string location) where TObject : UnityEngine.Object
|
||||
{
|
||||
return _mainPackage.LoadAssetSync<TObject>(location);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAssetSync<TObject>(location);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -208,7 +161,8 @@ namespace YooAsset
|
||||
/// <param name="type">资源类型</param>
|
||||
public static AssetOperationHandle LoadAssetSync(string location, System.Type type)
|
||||
{
|
||||
return _mainPackage.LoadAssetSync(location, type);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAssetSync(location, type);
|
||||
}
|
||||
|
||||
|
||||
@@ -218,7 +172,8 @@ namespace YooAsset
|
||||
/// <param name="assetInfo">资源信息</param>
|
||||
public static AssetOperationHandle LoadAssetAsync(AssetInfo assetInfo)
|
||||
{
|
||||
return _mainPackage.LoadAssetAsync(assetInfo);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAssetAsync(assetInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -228,7 +183,8 @@ namespace YooAsset
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static AssetOperationHandle LoadAssetAsync<TObject>(string location) where TObject : UnityEngine.Object
|
||||
{
|
||||
return _mainPackage.LoadAssetAsync<TObject>(location);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAssetAsync<TObject>(location);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -238,7 +194,8 @@ namespace YooAsset
|
||||
/// <param name="type">资源类型</param>
|
||||
public static AssetOperationHandle LoadAssetAsync(string location, System.Type type)
|
||||
{
|
||||
return _mainPackage.LoadAssetAsync(location, type);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAssetAsync(location, type);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -249,7 +206,8 @@ namespace YooAsset
|
||||
/// <param name="assetInfo">资源信息</param>
|
||||
public static SubAssetsOperationHandle LoadSubAssetsSync(AssetInfo assetInfo)
|
||||
{
|
||||
return _mainPackage.LoadSubAssetsSync(assetInfo);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadSubAssetsSync(assetInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -259,7 +217,8 @@ namespace YooAsset
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static SubAssetsOperationHandle LoadSubAssetsSync<TObject>(string location) where TObject : UnityEngine.Object
|
||||
{
|
||||
return _mainPackage.LoadSubAssetsSync<TObject>(location);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadSubAssetsSync<TObject>(location);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -269,7 +228,8 @@ namespace YooAsset
|
||||
/// <param name="type">子对象类型</param>
|
||||
public static SubAssetsOperationHandle LoadSubAssetsSync(string location, System.Type type)
|
||||
{
|
||||
return _mainPackage.LoadSubAssetsSync(location, type);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadSubAssetsSync(location, type);
|
||||
}
|
||||
|
||||
|
||||
@@ -279,7 +239,8 @@ namespace YooAsset
|
||||
/// <param name="assetInfo">资源信息</param>
|
||||
public static SubAssetsOperationHandle LoadSubAssetsAsync(AssetInfo assetInfo)
|
||||
{
|
||||
return _mainPackage.LoadSubAssetsAsync(assetInfo);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadSubAssetsAsync(assetInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -289,7 +250,8 @@ namespace YooAsset
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static SubAssetsOperationHandle LoadSubAssetsAsync<TObject>(string location) where TObject : UnityEngine.Object
|
||||
{
|
||||
return _mainPackage.LoadSubAssetsAsync<TObject>(location);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadSubAssetsAsync<TObject>(location);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -299,7 +261,8 @@ namespace YooAsset
|
||||
/// <param name="type">子对象类型</param>
|
||||
public static SubAssetsOperationHandle LoadSubAssetsAsync(string location, System.Type type)
|
||||
{
|
||||
return _mainPackage.LoadSubAssetsAsync(location, type);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadSubAssetsAsync(location, type);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -312,7 +275,8 @@ namespace YooAsset
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
public static PatchDownloaderOperation CreatePatchDownloader(string tag, int downloadingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
return _mainPackage.CreatePatchDownloader(new string[] { tag }, downloadingMaxNumber, failedTryAgain);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.CreatePatchDownloader(new string[] { tag }, downloadingMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -323,7 +287,8 @@ namespace YooAsset
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
public static PatchDownloaderOperation CreatePatchDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
return _mainPackage.CreatePatchDownloader(tags, downloadingMaxNumber, failedTryAgain);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.CreatePatchDownloader(tags, downloadingMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -333,7 +298,8 @@ namespace YooAsset
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
public static PatchDownloaderOperation CreatePatchDownloader(int downloadingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
return _mainPackage.CreatePatchDownloader(downloadingMaxNumber, failedTryAgain);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.CreatePatchDownloader(downloadingMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
|
||||
@@ -345,7 +311,8 @@ namespace YooAsset
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
public static PatchDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
return _mainPackage.CreateBundleDownloader(locations, downloadingMaxNumber, failedTryAgain);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.CreateBundleDownloader(locations, downloadingMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -356,7 +323,8 @@ namespace YooAsset
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
public static PatchDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
return _mainPackage.CreateBundleDownloader(assetInfos, downloadingMaxNumber, failedTryAgain);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.CreateBundleDownloader(assetInfos, downloadingMaxNumber, failedTryAgain);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -369,7 +337,8 @@ namespace YooAsset
|
||||
/// <param name="failedTryAgain">解压失败的重试次数</param>
|
||||
public static PatchUnpackerOperation CreatePatchUnpacker(string tag, int unpackingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
return _mainPackage.CreatePatchUnpacker(tag, unpackingMaxNumber, failedTryAgain);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.CreatePatchUnpacker(tag, unpackingMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -380,7 +349,8 @@ namespace YooAsset
|
||||
/// <param name="failedTryAgain">解压失败的重试次数</param>
|
||||
public static PatchUnpackerOperation CreatePatchUnpacker(string[] tags, int unpackingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
return _mainPackage.CreatePatchUnpacker(tags, unpackingMaxNumber, failedTryAgain);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.CreatePatchUnpacker(tags, unpackingMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -390,7 +360,8 @@ namespace YooAsset
|
||||
/// <param name="failedTryAgain">解压失败的重试次数</param>
|
||||
public static PatchUnpackerOperation CreatePatchUnpacker(int unpackingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
return _mainPackage.CreatePatchUnpacker(unpackingMaxNumber, failedTryAgain);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.CreatePatchUnpacker(unpackingMaxNumber, failedTryAgain);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -402,7 +373,17 @@ namespace YooAsset
|
||||
/// <param name="timeout">超时时间</param>
|
||||
public static UpdatePackageOperation UpdatePackageAsync(string packageCRC, int timeout = 60)
|
||||
{
|
||||
return _mainPackage.UpdatePackageAsync(packageCRC, timeout);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.UpdatePackageAsync(packageCRC, timeout);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 调试方法
|
||||
[Conditional("DEBUG")]
|
||||
private static void DebugCheckDefaultPackageValid()
|
||||
{
|
||||
if (_defaultPackage == null)
|
||||
throw new Exception($"Default package is null. Please use {nameof(YooAssets.SetDefaultAssetsPackage)} !");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -43,32 +43,35 @@ public class BootScene : MonoBehaviour
|
||||
// 初始化资源系统
|
||||
YooAssets.Initialize();
|
||||
|
||||
// 创建默认的资源包
|
||||
var defaultPackage = YooAssets.CreateAssetsPackage("DefaultPackage");
|
||||
|
||||
// 设置该资源包为默认的资源包
|
||||
YooAssets.SetDefaultAssetsPackage(defaultPackage);
|
||||
|
||||
// 编辑器下的模拟模式
|
||||
if (PlayMode == EPlayMode.EditorSimulateMode)
|
||||
{
|
||||
var createParameters = new EditorSimulateModeParameters();
|
||||
createParameters.LocationServices = new AddressLocationServices();
|
||||
createParameters.SimulatePatchManifestPath = EditorSimulateModeHelper.SimulateBuild("DefaultPackage", true);
|
||||
yield return YooAssets.InitializeAsync(createParameters);
|
||||
createParameters.SimulatePatchManifestPath = EditorSimulateModeHelper.SimulateBuild("DefaultPackage");
|
||||
yield return defaultPackage.InitializeAsync(createParameters);
|
||||
}
|
||||
|
||||
// 单机运行模式
|
||||
if (PlayMode == EPlayMode.OfflinePlayMode)
|
||||
{
|
||||
var createParameters = new OfflinePlayModeParameters();
|
||||
createParameters.LocationServices = new AddressLocationServices();
|
||||
yield return YooAssets.InitializeAsync(createParameters);
|
||||
yield return defaultPackage.InitializeAsync(createParameters);
|
||||
}
|
||||
|
||||
// 联机运行模式
|
||||
if (PlayMode == EPlayMode.HostPlayMode)
|
||||
{
|
||||
var createParameters = new HostPlayModeParameters();
|
||||
createParameters.LocationServices = new AddressLocationServices();
|
||||
createParameters.QueryServices = new QueryStreamingAssetsFileServices();
|
||||
createParameters.DefaultHostServer = GetHostServerURL();
|
||||
createParameters.FallbackHostServer = GetHostServerURL();
|
||||
yield return YooAssets.InitializeAsync(createParameters);
|
||||
yield return defaultPackage.InitializeAsync(createParameters);
|
||||
}
|
||||
|
||||
// 运行补丁流程
|
||||
@@ -105,7 +108,8 @@ public class BootScene : MonoBehaviour
|
||||
{
|
||||
public bool QueryStreamingAssets(string fileName)
|
||||
{
|
||||
return BetterStreamingAssets.FileExists($"YooAssets/{fileName}");
|
||||
string buildinFolderName = YooAssets.GetStreamingAssetBuildinFolderName();
|
||||
return BetterStreamingAssets.FileExists($"{buildinFolderName}/{fileName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,8 @@ public class GameScene1 : MonoBehaviour
|
||||
|
||||
void Start()
|
||||
{
|
||||
YooAssets.UnloadUnusedAssets();
|
||||
var package = YooAssets.GetAssetsPackage("DefaultPackage");
|
||||
package.UnloadUnusedAssets();
|
||||
|
||||
// 初始化窗口
|
||||
InitWindow();
|
||||
|
||||
@@ -14,7 +14,8 @@ public class GameScene2 : MonoBehaviour
|
||||
|
||||
void Start()
|
||||
{
|
||||
YooAssets.UnloadUnusedAssets();
|
||||
var package = YooAssets.GetAssetsPackage("DefaultPackage");
|
||||
package.UnloadUnusedAssets();
|
||||
|
||||
// 初始化窗口
|
||||
InitWindow();
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
internal class FsmClearCache : IFsmNode
|
||||
{
|
||||
public string Name { private set; get; } = nameof(FsmClearCache);
|
||||
|
||||
void IFsmNode.OnEnter()
|
||||
{
|
||||
Debug.Log("清理未使用的缓存文件!");
|
||||
var operation = YooAsset.YooAssets.ClearUnusedCacheFiles();
|
||||
operation.Completed += Operation_Completed;
|
||||
}
|
||||
|
||||
private void Operation_Completed(YooAsset.AsyncOperationBase obj)
|
||||
{
|
||||
Debug.Log("开始游戏!");
|
||||
YooAsset.YooAssets.LoadSceneAsync("GameScene1");
|
||||
}
|
||||
|
||||
void IFsmNode.OnUpdate()
|
||||
{
|
||||
}
|
||||
void IFsmNode.OnExit()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d83ce785f1442a40a1ad0f837073b69
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -11,7 +11,7 @@ internal class FsmPatchDone : IFsmNode
|
||||
PatchEventDispatcher.SendPatchStepsChangeMsg(EPatchStates.PatchDone);
|
||||
Debug.Log("补丁流程更新完毕!");
|
||||
|
||||
YooAsset.YooAssets.LoadSceneAsync("GameScene1");
|
||||
FsmManager.Transition(nameof(FsmClearCache));
|
||||
}
|
||||
void IFsmNode.OnUpdate()
|
||||
{
|
||||
|
||||
@@ -24,7 +24,8 @@ public class FsmUpdateManifest : IFsmNode
|
||||
yield return new WaitForSecondsRealtime(0.5f);
|
||||
|
||||
// 更新补丁清单
|
||||
var operation = YooAssets.UpdateManifestAsync(PatchUpdater.PackageCRC, 30);
|
||||
var package = YooAssets.GetAssetsPackage("DefaultPackage");
|
||||
var operation = package.UpdateManifestAsync(PatchUpdater.PackageCRC, 30);
|
||||
yield return operation;
|
||||
|
||||
if(operation.Status == EOperationStatus.Succeed)
|
||||
|
||||
@@ -24,7 +24,8 @@ internal class FsmUpdateStaticVersion : IFsmNode
|
||||
yield return new WaitForSecondsRealtime(0.5f);
|
||||
|
||||
// 更新资源版本号
|
||||
var operation = YooAssets.UpdateStaticVersionAsync(30);
|
||||
var package = YooAssets.GetAssetsPackage("DefaultPackage");
|
||||
var operation = package.UpdateStaticVersionAsync(30);
|
||||
yield return operation;
|
||||
|
||||
if (operation.Status == EOperationStatus.Succeed)
|
||||
|
||||
@@ -36,6 +36,7 @@ public static class PatchUpdater
|
||||
FsmManager.AddNode(new FsmCreateDownloader());
|
||||
FsmManager.AddNode(new FsmDownloadWebFiles());
|
||||
FsmManager.AddNode(new FsmPatchDone());
|
||||
FsmManager.AddNode(new FsmClearCache());
|
||||
FsmManager.Run(nameof(FsmPatchInit));
|
||||
}
|
||||
else
|
||||
|
||||
@@ -15,7 +15,8 @@ MonoBehaviour:
|
||||
BuildPipeline: 0
|
||||
BuildMode: 1
|
||||
BuildPackage: DefaultPackage
|
||||
BuildTags: buildin;
|
||||
CompressOption: 2
|
||||
OutputNameStyle: 1
|
||||
CopyBuildinFileOption: 1
|
||||
CopyBuildinFileTags:
|
||||
EncyptionClassName: EncryptionNone
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root Version="2.0">
|
||||
<Common AutoAddressable="True" ShowPackageView="False" />
|
||||
<root Version="2.1">
|
||||
<Common AutoAddressable="True" UniqueBundleName="False" ShowPackageView="False" />
|
||||
<Package PackageName="DefaultPackage" PackageDesc="">
|
||||
<Group GroupName="Level" GroupDesc="关卡资源" AssetTags="level">
|
||||
<Collector CollectPath="Assets/YooAsset/Samples/Basic Sample/GameRes/Entity/Level1" CollectGUID="724066efe61192e43a0d7e59166b36a4" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackSeparately" FilterRule="CollectPrefab" AssetTags="level1" />
|
||||
<Collector CollectPath="Assets/YooAsset/Samples/Basic Sample/GameRes/Entity/Level2" CollectGUID="8045c1986f0ae964f8b1ea29e3522388" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackSeparately" FilterRule="CollectPrefab" AssetTags="level2" />
|
||||
<Collector CollectPath="Assets/Samples/Basic Sample/GameRes/Entity/Level1" CollectGUID="724066efe61192e43a0d7e59166b36a4" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackSeparately" FilterRule="CollectPrefab" AssetTags="level1" />
|
||||
<Collector CollectPath="Assets/Samples/Basic Sample/GameRes/Entity/Level2" CollectGUID="8045c1986f0ae964f8b1ea29e3522388" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackSeparately" FilterRule="CollectPrefab" AssetTags="level2" />
|
||||
</Group>
|
||||
<Group GroupName="Buildin" GroupDesc="首包资源" AssetTags="buildin">
|
||||
<Collector CollectPath="Assets/YooAsset/Samples/Basic Sample/GameRes/Scene" CollectGUID="f75e7d64104fb1a48b849b72b84ade4c" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackSeparately" FilterRule="CollectScene" AssetTags="" />
|
||||
<Collector CollectPath="Assets/YooAsset/Samples/Basic Sample/GameRes/Config" CollectGUID="44774abdee2b91b45b42f9dadf8c17a4" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackRawFile" FilterRule="CollectAll" AssetTags="" />
|
||||
<Collector CollectPath="Assets/YooAsset/Samples/Basic Sample/GameRes/Music" CollectGUID="e05b02ee4d90ae84a99871ce75288ea2" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
|
||||
<Collector CollectPath="Assets/Samples/Basic Sample/GameRes/Scene" CollectGUID="f75e7d64104fb1a48b849b72b84ade4c" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackSeparately" FilterRule="CollectScene" AssetTags="" />
|
||||
<Collector CollectPath="Assets/Samples/Basic Sample/GameRes/Config" CollectGUID="44774abdee2b91b45b42f9dadf8c17a4" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackRawFile" FilterRule="CollectAll" AssetTags="" />
|
||||
<Collector CollectPath="Assets/Samples/Basic Sample/GameRes/Music" CollectGUID="e05b02ee4d90ae84a99871ce75288ea2" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
|
||||
</Group>
|
||||
<Group GroupName="Panel" GroupDesc="面板资源" AssetTags="panel">
|
||||
<Collector CollectPath="Assets/YooAsset/Samples/Basic Sample/GameRes/Texture" CollectGUID="69b046f60ca75f647b2963e0113fd779" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackCollector" FilterRule="CollectAll" AssetTags="" />
|
||||
<Collector CollectPath="Assets/YooAsset/Samples/Basic Sample/GameRes/TpAtlas" CollectGUID="06e38aac2570d2b4a97c6a90223e5344" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
|
||||
<Collector CollectPath="Assets/YooAsset/Samples/Basic Sample/GameRes/UIPanel" CollectGUID="926d3203fcefdb947881a7491496e039" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
|
||||
<Collector CollectPath="Assets/YooAsset/Samples/Basic Sample/GameRes/UISprite" CollectGUID="29f27e4abf667c04b88a3996d8cdadfc" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
|
||||
<Collector CollectPath="Assets/Samples/Basic Sample/GameRes/Texture" CollectGUID="69b046f60ca75f647b2963e0113fd779" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackCollector" FilterRule="CollectAll" AssetTags="" />
|
||||
<Collector CollectPath="Assets/Samples/Basic Sample/GameRes/TpAtlas" CollectGUID="06e38aac2570d2b4a97c6a90223e5344" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
|
||||
<Collector CollectPath="Assets/Samples/Basic Sample/GameRes/UIPanel" CollectGUID="926d3203fcefdb947881a7491496e039" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
|
||||
<Collector CollectPath="Assets/Samples/Basic Sample/GameRes/UISprite" CollectGUID="29f27e4abf667c04b88a3996d8cdadfc" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
|
||||
</Group>
|
||||
<Group GroupName="Art" GroupDesc="美术资源" AssetTags="">
|
||||
<Collector CollectPath="Assets/YooAsset/Samples/Basic Sample/GameArt/ShaderVariants" CollectGUID="00781758c26692e40a9634ddeac838be" CollectType="StaticAssetCollector" AddressRule="AddressByFileName" PackRule="PackShaderVariants" FilterRule="CollectAll" AssetTags="" />
|
||||
<Collector CollectPath="Assets/YooAsset/Samples/Basic Sample/GameArt/UIFont" CollectGUID="464727a15e4a7dc4d895346374432399" CollectType="DependAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
|
||||
<Collector CollectPath="Assets/Samples/Basic Sample/GameArt/ShaderVariants" CollectGUID="00781758c26692e40a9634ddeac838be" CollectType="StaticAssetCollector" AddressRule="AddressByFileName" PackRule="PackShaderVariants" FilterRule="CollectAll" AssetTags="" />
|
||||
<Collector CollectPath="Assets/Samples/Basic Sample/GameArt/UIFont" CollectGUID="464727a15e4a7dc4d895346374432399" CollectType="DependAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" AssetTags="" />
|
||||
</Group>
|
||||
</Package>
|
||||
</root>
|
||||
@@ -14,6 +14,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
ShowPackageView: 0
|
||||
EnableAddressable: 1
|
||||
UniqueBundleName: 0
|
||||
Packages:
|
||||
- PackageName: DefaultPackage
|
||||
PackageDesc:
|
||||
@@ -23,14 +24,14 @@ MonoBehaviour:
|
||||
AssetTags: level
|
||||
ActiveRuleName: EnableGroup
|
||||
Collectors:
|
||||
- CollectPath: Assets/YooAsset/Samples/Basic Sample/GameRes/Entity/Level1
|
||||
- CollectPath: Assets/Samples/Basic Sample/GameRes/Entity/Level1
|
||||
CollectorGUID: 724066efe61192e43a0d7e59166b36a4
|
||||
CollectorType: 0
|
||||
AddressRuleName: AddressByFileName
|
||||
PackRuleName: PackSeparately
|
||||
FilterRuleName: CollectPrefab
|
||||
AssetTags: level1
|
||||
- CollectPath: Assets/YooAsset/Samples/Basic Sample/GameRes/Entity/Level2
|
||||
- CollectPath: Assets/Samples/Basic Sample/GameRes/Entity/Level2
|
||||
CollectorGUID: 8045c1986f0ae964f8b1ea29e3522388
|
||||
CollectorType: 0
|
||||
AddressRuleName: AddressByFileName
|
||||
@@ -42,21 +43,21 @@ MonoBehaviour:
|
||||
AssetTags: buildin
|
||||
ActiveRuleName: EnableGroup
|
||||
Collectors:
|
||||
- CollectPath: Assets/YooAsset/Samples/Basic Sample/GameRes/Scene
|
||||
- CollectPath: Assets/Samples/Basic Sample/GameRes/Scene
|
||||
CollectorGUID: f75e7d64104fb1a48b849b72b84ade4c
|
||||
CollectorType: 0
|
||||
AddressRuleName: AddressByFileName
|
||||
PackRuleName: PackSeparately
|
||||
FilterRuleName: CollectScene
|
||||
AssetTags:
|
||||
- CollectPath: Assets/YooAsset/Samples/Basic Sample/GameRes/Config
|
||||
- CollectPath: Assets/Samples/Basic Sample/GameRes/Config
|
||||
CollectorGUID: 44774abdee2b91b45b42f9dadf8c17a4
|
||||
CollectorType: 0
|
||||
AddressRuleName: AddressByFileName
|
||||
PackRuleName: PackRawFile
|
||||
FilterRuleName: CollectAll
|
||||
AssetTags:
|
||||
- CollectPath: Assets/YooAsset/Samples/Basic Sample/GameRes/Music
|
||||
- CollectPath: Assets/Samples/Basic Sample/GameRes/Music
|
||||
CollectorGUID: e05b02ee4d90ae84a99871ce75288ea2
|
||||
CollectorType: 0
|
||||
AddressRuleName: AddressByFileName
|
||||
@@ -68,28 +69,28 @@ MonoBehaviour:
|
||||
AssetTags: panel
|
||||
ActiveRuleName: EnableGroup
|
||||
Collectors:
|
||||
- CollectPath: Assets/YooAsset/Samples/Basic Sample/GameRes/Texture
|
||||
- CollectPath: Assets/Samples/Basic Sample/GameRes/Texture
|
||||
CollectorGUID: 69b046f60ca75f647b2963e0113fd779
|
||||
CollectorType: 0
|
||||
AddressRuleName: AddressByFileName
|
||||
PackRuleName: PackCollector
|
||||
FilterRuleName: CollectAll
|
||||
AssetTags:
|
||||
- CollectPath: Assets/YooAsset/Samples/Basic Sample/GameRes/TpAtlas
|
||||
- CollectPath: Assets/Samples/Basic Sample/GameRes/TpAtlas
|
||||
CollectorGUID: 06e38aac2570d2b4a97c6a90223e5344
|
||||
CollectorType: 0
|
||||
AddressRuleName: AddressByFileName
|
||||
PackRuleName: PackDirectory
|
||||
FilterRuleName: CollectAll
|
||||
AssetTags:
|
||||
- CollectPath: Assets/YooAsset/Samples/Basic Sample/GameRes/UIPanel
|
||||
- CollectPath: Assets/Samples/Basic Sample/GameRes/UIPanel
|
||||
CollectorGUID: 926d3203fcefdb947881a7491496e039
|
||||
CollectorType: 0
|
||||
AddressRuleName: AddressByFileName
|
||||
PackRuleName: PackDirectory
|
||||
FilterRuleName: CollectAll
|
||||
AssetTags:
|
||||
- CollectPath: Assets/YooAsset/Samples/Basic Sample/GameRes/UISprite
|
||||
- CollectPath: Assets/Samples/Basic Sample/GameRes/UISprite
|
||||
CollectorGUID: 29f27e4abf667c04b88a3996d8cdadfc
|
||||
CollectorType: 0
|
||||
AddressRuleName: AddressByFileName
|
||||
@@ -101,14 +102,14 @@ MonoBehaviour:
|
||||
AssetTags:
|
||||
ActiveRuleName: EnableGroup
|
||||
Collectors:
|
||||
- CollectPath: Assets/YooAsset/Samples/Basic Sample/GameArt/ShaderVariants
|
||||
- CollectPath: Assets/Samples/Basic Sample/GameArt/ShaderVariants
|
||||
CollectorGUID: 00781758c26692e40a9634ddeac838be
|
||||
CollectorType: 1
|
||||
AddressRuleName: AddressByFileName
|
||||
PackRuleName: PackShaderVariants
|
||||
FilterRuleName: CollectAll
|
||||
AssetTags:
|
||||
- CollectPath: Assets/YooAsset/Samples/Basic Sample/GameArt/UIFont
|
||||
- CollectPath: Assets/Samples/Basic Sample/GameArt/UIFont
|
||||
CollectorGUID: 464727a15e4a7dc4d895346374432399
|
||||
CollectorType: 2
|
||||
AddressRuleName: AddressByFileName
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user