Compare commits
36 Commits
1.3.0-prev
...
1.3.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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
@@ -58,7 +58,4 @@ sysinfo.txt
|
||||
# Crashlytics generated file
|
||||
crashlytics-build.properties
|
||||
|
||||
*.vsconfig
|
||||
|
||||
Sandbox/
|
||||
Bundles/
|
||||
*.vsconfig
|
||||
@@ -2,6 +2,91 @@
|
||||
|
||||
All notable changes to this package will be documented in this file.
|
||||
|
||||
## [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()
|
||||
{
|
||||
@@ -233,6 +261,8 @@ namespace YooAsset.Editor
|
||||
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,7 @@ namespace YooAsset.Editor
|
||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
||||
buildParameters.BuildPackage = packageName;
|
||||
buildParameters.EnableAddressable = enableAddressable;
|
||||
buildParameters.EnableAddressable = AssetBundleCollectorSettingData.Setting.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;
|
||||
|
||||
@@ -89,14 +89,6 @@ namespace YooAsset.Editor
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取文件的扩展名
|
||||
/// </summary>
|
||||
public string GetAppendExtension()
|
||||
{
|
||||
return System.IO.Path.GetExtension(BundleName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建的资源路径列表
|
||||
/// </summary>
|
||||
|
||||
@@ -61,6 +61,11 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public string BuildPackage;
|
||||
|
||||
/// <summary>
|
||||
/// 人类可读的版本信息
|
||||
/// </summary>
|
||||
public string HumanReadableVersion;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 验证构建结果
|
||||
@@ -82,6 +87,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>
|
||||
|
||||
@@ -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: 057a358d2d0c92b47add59dac8bef783
|
||||
guid: 5c77e17c3a3a57548a218f1cd26f5a55
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -31,6 +31,7 @@ namespace YooAsset.Editor
|
||||
patchManifest.EnableAddressable = buildParameters.EnableAddressable;
|
||||
patchManifest.OutputNameStyle = (int)buildParameters.OutputNameStyle;
|
||||
patchManifest.PackageName = buildParameters.BuildPackage;
|
||||
patchManifest.HumanReadableVersion = buildParameters.HumanReadableVersion;
|
||||
patchManifest.BundleList = GetAllPatchBundle(context);
|
||||
patchManifest.AssetList = GetAllPatchAsset(context, patchManifest);
|
||||
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4defd475b635cdf4b87108140d3a0ad1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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);
|
||||
|
||||
@@ -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,7 +6,7 @@ using UnityEngine.SceneManagement;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
public class YooAssetPackage
|
||||
public class AssetsPackage
|
||||
{
|
||||
private bool _isInitialize = false;
|
||||
private string _initializeError = string.Empty;
|
||||
@@ -25,21 +25,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()
|
||||
internal AssetsPackage()
|
||||
{
|
||||
}
|
||||
internal YooAssetPackage(string packageName)
|
||||
internal AssetsPackage(string packageName)
|
||||
{
|
||||
PackageName = packageName;
|
||||
}
|
||||
@@ -136,10 +133,10 @@ 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)
|
||||
@@ -149,7 +146,7 @@ namespace YooAsset
|
||||
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))
|
||||
@@ -280,6 +277,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>
|
||||
@@ -693,10 +714,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 +727,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 +752,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 +779,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 +797,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 +811,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 +857,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 +887,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
|
||||
{
|
||||
@@ -921,6 +947,17 @@ namespace YooAsset
|
||||
{
|
||||
return _bundleServices.MappingToAssetPath(location);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否包含资源文件
|
||||
/// </summary>
|
||||
internal bool IsIncludeBundleFile(string fileName)
|
||||
{
|
||||
// NOTE : 编辑器模拟模式下始终返回TRUE
|
||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||
return true;
|
||||
return _bundleServices.IsIncludeBundleFile(fileName);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 调试方法
|
||||
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
@@ -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
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6296859f09655c4191594304ddf378f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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();
|
||||
@@ -109,7 +113,7 @@ namespace YooAsset
|
||||
if (_steps == ESteps.CheckDownload)
|
||||
{
|
||||
_downloadProgress = _webRequest.downloadProgress;
|
||||
_downloadedBytes = _webRequest.downloadedBytes;
|
||||
_downloadedBytes = _fileOriginLength + _webRequest.downloadedBytes;
|
||||
if (_webRequest.isDone == false)
|
||||
{
|
||||
CheckTimeout();
|
||||
@@ -226,7 +230,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,
|
||||
|
||||
|
||||
@@ -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>
|
||||
@@ -212,6 +217,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;
|
||||
@@ -61,6 +70,10 @@ namespace YooAsset
|
||||
{
|
||||
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;
|
||||
@@ -354,6 +396,10 @@ namespace YooAsset
|
||||
{
|
||||
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;
|
||||
@@ -89,6 +121,10 @@ namespace YooAsset
|
||||
{
|
||||
return _appPatchManifest.PackageName;
|
||||
}
|
||||
bool IBundleServices.IsIncludeBundleFile(string fileName)
|
||||
{
|
||||
return _appPatchManifest.IsIncludeBundleFile(fileName);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -32,5 +32,10 @@ namespace YooAsset
|
||||
/// 获取所属的包裹名
|
||||
/// </summary>
|
||||
string GetPackageName();
|
||||
|
||||
/// <summary>
|
||||
/// 是否包含资源文件
|
||||
/// </summary>
|
||||
bool IsIncludeBundleFile(string fileName);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,6 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 定位地址转换为资源路径
|
||||
/// </summary>
|
||||
string ConvertLocationToAssetPath(YooAssetPackage package, string location);
|
||||
string ConvertLocationToAssetPath(AssetsPackage package, string location);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ namespace YooAsset
|
||||
{
|
||||
public class AddressLocationServices : ILocationServices
|
||||
{
|
||||
string ILocationServices.ConvertLocationToAssetPath(YooAssetPackage package, string location)
|
||||
string ILocationServices.ConvertLocationToAssetPath(AssetsPackage package, string location)
|
||||
{
|
||||
return package.MappingToAssetPath(location);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace YooAsset
|
||||
_resourceRoot = PathHelper.GetRegularPath(resourceRoot);
|
||||
}
|
||||
|
||||
string ILocationServices.ConvertLocationToAssetPath(YooAssetPackage package, string location)
|
||||
string ILocationServices.ConvertLocationToAssetPath(AssetsPackage package, string location)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_resourceRoot))
|
||||
{
|
||||
|
||||
@@ -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>
|
||||
@@ -151,6 +177,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 +210,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,7 +65,8 @@ namespace YooAsset
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static AssetInfo GetAssetInfo(string location)
|
||||
{
|
||||
return _mainPackage.GetAssetInfo(location);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.GetAssetInfo(location);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -129,7 +76,8 @@ namespace YooAsset
|
||||
/// <returns>如果location地址无效,则返回空字符串</returns>
|
||||
public static string GetAssetPath(string location)
|
||||
{
|
||||
return _mainPackage.GetAssetPath(location);
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.GetAssetPath(location);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -141,7 +89,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 +100,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 +115,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 +128,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 +140,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 +151,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 +162,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 +173,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 +184,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 +195,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 +207,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 +218,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 +229,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 +240,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 +251,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 +262,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 +276,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 +288,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 +299,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 +312,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 +324,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 +338,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 +350,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 +361,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 +374,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,13 +43,19 @@ 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);
|
||||
}
|
||||
|
||||
// 单机运行模式
|
||||
@@ -57,7 +63,7 @@ public class BootScene : MonoBehaviour
|
||||
{
|
||||
var createParameters = new OfflinePlayModeParameters();
|
||||
createParameters.LocationServices = new AddressLocationServices();
|
||||
yield return YooAssets.InitializeAsync(createParameters);
|
||||
yield return defaultPackage.InitializeAsync(createParameters);
|
||||
}
|
||||
|
||||
// 联机运行模式
|
||||
@@ -68,7 +74,7 @@ public class BootScene : MonoBehaviour
|
||||
createParameters.QueryServices = new QueryStreamingAssetsFileServices();
|
||||
createParameters.DefaultHostServer = GetHostServerURL();
|
||||
createParameters.FallbackHostServer = GetHostServerURL();
|
||||
yield return YooAssets.InitializeAsync(createParameters);
|
||||
yield return defaultPackage.InitializeAsync(createParameters);
|
||||
}
|
||||
|
||||
// 运行补丁流程
|
||||
@@ -105,7 +111,7 @@ public class BootScene : MonoBehaviour
|
||||
{
|
||||
public bool QueryStreamingAssets(string fileName)
|
||||
{
|
||||
return BetterStreamingAssets.FileExists($"YooAssets/{fileName}");
|
||||
return BetterStreamingAssets.FileExists($"{YooAssets.GetStreamingAssetBuildinFolderName()}/{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
|
||||
|
||||
@@ -23,14 +23,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 +42,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 +68,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 +101,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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "com.tuyoogame.yooasset",
|
||||
"displayName": "YooAsset",
|
||||
"version": "1.3.0-preview",
|
||||
"version": "1.3.1",
|
||||
"unity": "2019.4",
|
||||
"description": "unity3d resources management system.",
|
||||
"author": {
|
||||
|
||||
@@ -8,10 +8,6 @@
|
||||
|
||||
构建输出的目录,会根据Unity编辑器当前切换的平台自动划分构建结果。
|
||||
|
||||
- **Build Version**
|
||||
|
||||
构建版本号,也是资源版本号,版本号必须大于零。
|
||||
|
||||
- **Build Pipeline**
|
||||
|
||||
构建管线
|
||||
@@ -32,6 +28,10 @@
|
||||
|
||||
(4) 模拟构建模式:在编辑器下配合EditorSimulateMode运行模式,来模拟真实运行的环境。
|
||||
|
||||
- **Build Package**
|
||||
|
||||
需要构建的资源包名称。
|
||||
|
||||
- **Encryption**
|
||||
|
||||
加密类列表。
|
||||
@@ -52,10 +52,6 @@
|
||||
|
||||
(4) BundleName_HashName_Extension:资源包名+哈希值+后缀名
|
||||
|
||||
- **Buildin Tags**
|
||||
|
||||
标记为安装包里的资源标签列表。构建成功后,会将相关标记的资源包拷贝到StreamingAssets文件夹下。
|
||||
|
||||
- **构建**
|
||||
|
||||
点击构建按钮会开始构建流程,构建流程分为多个节点顺序执行,如果某个节点发生错误,会导致构建失败。错误信息可以在控制台查看。
|
||||
@@ -98,8 +94,6 @@ public class GameEncryption : IEncryptionServices
|
||||
|
||||
补丁包文件夹里包含补丁清单文件,资源包文件,构建报告文件等。
|
||||
|
||||
资源包文件都是以文件的哈希值命名。
|
||||
|
||||

|
||||
|
||||
### 补丁清单
|
||||
@@ -119,9 +113,6 @@ private static void BuildInternal(BuildTarget buildTarget)
|
||||
{
|
||||
Debug.Log($"开始构建 : {buildTarget}");
|
||||
|
||||
// 命令行参数
|
||||
int buildVersion = GetBuildVersion();
|
||||
|
||||
// 构建参数
|
||||
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultOutputRoot();
|
||||
BuildParameters buildParameters = new BuildParameters();
|
||||
@@ -129,14 +120,12 @@ private static void BuildInternal(BuildTarget buildTarget)
|
||||
buildParameters.BuildTarget = buildTarget;
|
||||
buildParameters.BuildPipeline = EBuildPipeline.BuiltinBuildPipeline;
|
||||
buildParameters.BuildMode = EBuildMode.ForceRebuild;
|
||||
buildParameters.BuildVersion = buildVersion;
|
||||
buildParameters.BuildinTags = "buildin";
|
||||
buildParameters.BuildPackage = "DefaultPackage";
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.EnableAddressable = false;
|
||||
buildParameters.AppendFileExtension = false;
|
||||
buildParameters.CopyBuildinTagFiles = true;
|
||||
buildParameters.EnableAddressable = true;
|
||||
buildParameters.EncryptionServices = new GameEncryption();
|
||||
buildParameters.CompressOption = ECompressOption.LZ4;
|
||||
buildParameters.OutputNameStyle = EOutputNameStyle.HashName_Extension;
|
||||
|
||||
// 执行构建
|
||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||
@@ -146,12 +135,12 @@ private static void BuildInternal(BuildTarget buildTarget)
|
||||
}
|
||||
|
||||
// 从构建命令里获取参数
|
||||
private static int GetBuildVersion()
|
||||
private static string GetBuildPackageName()
|
||||
{
|
||||
foreach (string arg in System.Environment.GetCommandLineArgs())
|
||||
{
|
||||
if (arg.StartsWith("buildVersion"))
|
||||
return int.Parse(arg.Split("="[0])[1]);
|
||||
if (arg.StartsWith("buildPackage"))
|
||||
return arg.Split("="[0])[1];
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -167,14 +156,10 @@ private static int GetBuildVersion()
|
||||
|
||||
强制构建是每次构建之前,都会清空之前构建的所有缓存文件,以此来重新构建资源包。
|
||||
|
||||
- **资源版本号**
|
||||
|
||||
资源版本号实际上只是构建结果的一个标记符号,在构建的时间轴上记录着每次打包的标记符号,此外资源版本号没有任何作用。
|
||||
|
||||
- **首包资源**
|
||||
|
||||
在构建应用程序的时候(例如安卓的APK),我们希望将某些资源打进首包里,可以通过设置Buildin Tags资源标签来决定哪些资源打进首包。首包资源如果发生变化,也可以通过热更新来更新资源。
|
||||
在构建应用程序的时候(例如安卓的APK),我们希望将某些资源打进首包里,可以在构建成功后自己编写逻辑代码拷贝相关资源文件到StreamingAssets/YooAssets/目录里。首包资源如果发生变化,也可以通过热更新来更新资源。
|
||||
|
||||
- **补丁包**
|
||||
|
||||
无论是通过增量构建还是强制构建,在构建完成后都会生成一个以资源版本号命名的文件夹,我们把这个文件夹和里面的资源统称为补丁包。补丁包里包含了游戏运行需要的所有资源,我们可以无脑的将补丁包内容覆盖到CDN目录下,也可以通过编写差异分析工具,来筛选出和线上最新版本之间的差异文件,然后将差异文件上传到CDN目录里。
|
||||
无论是通过增量构建还是强制构建,在构建完成后都会生成一个以补丁清单文件哈希值命名的文件夹,我们把这个文件夹统称为补丁包。补丁包里包含了游戏运行需要的所有资源,我们可以无脑的将补丁包内容覆盖到CDN目录下,也可以通过编写差异分析工具,来筛选出和线上最新版本之间的差异文件,然后将差异文件上传到CDN目录里。
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
# 资源收集
|
||||
|
||||

|
||||

|
||||
|
||||
左侧为分组列表,右侧为该分组的配置界面。
|
||||
|
||||
导出按钮可以将配置数据导出为XML文件,导入按钮可以导入保存的XML文件。
|
||||
|
||||
**注意**:该工具仅支持Unity2019+
|
||||
**注意**:该工具仅支持Unity2019.4+
|
||||
|
||||
#### 公共设置
|
||||
|
||||
@@ -14,14 +14,6 @@
|
||||
|
||||
启用可寻址资源定位系统。
|
||||
|
||||
- Auto Collect Shaders
|
||||
|
||||
自动收集所有依赖的材质球使用的着色器,并将这些着色器打进一个资源包里。
|
||||
|
||||
- Shader Bundle Name
|
||||
|
||||
收集的着色器资源包名称。
|
||||
|
||||
#### 资源分组
|
||||
|
||||
- Active Rule
|
||||
@@ -102,9 +94,9 @@
|
||||
|
||||
打包规则,规则可以自定义扩展。下面是内置规则:
|
||||
|
||||
- PackSeparately 以文件路径作为资源包名,每个资源文件单独打包。
|
||||
- PackDirectory 以父类文件夹路径作为资源包名,文件夹下所有文件打进一个资源包。
|
||||
- PackTopDirectory 以收集器路径下顶级文件夹为资源包名,文件夹下所有文件打进一个资源包。
|
||||
- PackSeparately 以收集文件路径作为资源包名,每个资源文件单独打包。
|
||||
- PackDirectory 以收集文件所在的文件夹路径作为资源包名,该文件夹下所有文件打进一个资源包。
|
||||
- PackTopDirectory 以收集器路径下顶级文件夹为资源包名,该文件夹下所有文件打进一个资源包。
|
||||
- PackCollector 以收集器路径作为资源包名,收集的所有文件打进一个资源包。
|
||||
- PackGrouper 以分组名称作为资源包名,收集的所有文件打进一个资源包。
|
||||
- PackRawFile 目录下的资源文件会被处理为原生资源包。
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
可以查看资源对象列表信息(AssetView),资源包列表信息(BundleView)。
|
||||
|
||||
**注意**:该工具仅支持Unity2019+
|
||||
**注意**:该工具仅支持Unity2019.4+
|
||||
|
||||
### 真机远程调试注意事项
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
报告工具,可以查看概览信息(Summary),资源对象列表信息(AssetView),资源包列表信息(BundleView)。
|
||||
|
||||
**注意**:该工具仅支持Unity2019+
|
||||
**注意**:该工具仅支持Unity2019.4+
|
||||
|
||||
### 概览视图
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
# 初始化
|
||||
|
||||
资源系统的运行模式支持三种:编辑器模拟模式,单机运行模式,联机运行模式。
|
||||
初始化资源系统
|
||||
|
||||
````C#
|
||||
// 资源系统初始化方法,根据不同的模式,我们传递不同的创建参数类
|
||||
YooAssets.InitializeAsync(InitializeParameters parameters);
|
||||
````
|
||||
```c#
|
||||
YooAssets.Initialize();
|
||||
```
|
||||
|
||||
资源系统的运行模式支持三种:编辑器模拟模式,单机运行模式,联机运行模式。
|
||||
|
||||
**编辑器模拟模式**
|
||||
|
||||
@@ -18,6 +19,7 @@ private IEnumerator InitializeYooAsset()
|
||||
{
|
||||
var initParameters = new YooAssets.EditorSimulateModeParameters();
|
||||
initParameters.LocationServices = new DefaultLocationServices("Assets/GameRes");
|
||||
initParameters.SimulatePatchManifestPath = EditorSimulateModeHelper.SimulateBuild("DefaultPackage", false);
|
||||
yield return YooAssets.InitializeAsync(initParameters);
|
||||
}
|
||||
````
|
||||
@@ -53,8 +55,6 @@ private IEnumerator InitializeYooAsset()
|
||||
|
||||
- DecryptionServices : 如果资源包在构建的时候有加密,需要提供实现IDecryptionServices接口的实例类。
|
||||
|
||||
- ClearCacheWhenDirty : 安装包在覆盖安装的时候,是否清空沙盒缓存文件夹。
|
||||
|
||||
- DefaultHostServer : 默认的资源服务器IP地址。
|
||||
|
||||
- FallbackHostServer : 备用的资源服务器IP地址。
|
||||
@@ -66,24 +66,30 @@ private IEnumerator InitializeYooAsset()
|
||||
{
|
||||
var initParameters = new YooAssets.HostPlayModeParameters();
|
||||
initParameters.LocationServices = new DefaultLocationServices("Assets/GameRes");
|
||||
initParameters.DecryptionServices = null;
|
||||
initParameters.ClearCacheWhenDirty = false;
|
||||
initParameters.DecryptionServices = new BundleDecryptionServices();
|
||||
initParameters.QueryServices = new QueryStreamingAssetsServices();
|
||||
initParameters.DefaultHostServer = "http://127.0.0.1/CDN1/Android/v1.0";
|
||||
initParameters.FallbackHostServer = "http://127.0.0.1/CDN2/Android/v1.0";
|
||||
initParameters.VerifyLevel = EVerifyLevel.High;
|
||||
yield return YooAssets.InitializeAsync(initParameters);
|
||||
}
|
||||
````
|
||||
|
||||
**资源文件解密**
|
||||
|
||||
````c#
|
||||
public class BundleDecryption : IDecryptionServices
|
||||
// 文件解密服务类
|
||||
private class BundleDecryptionServices : IDecryptionServices
|
||||
{
|
||||
public ulong GetFileOffset(DecryptionFileInfo fileInfo)
|
||||
{
|
||||
return 32;
|
||||
}
|
||||
}
|
||||
|
||||
// 内置文件查询服务类
|
||||
private class QueryStreamingAssetsServices : IQueryServices
|
||||
{
|
||||
public bool QueryStreamingAssets(string fileName)
|
||||
{
|
||||
// 注意:使用了BetterStreamingAssets插件
|
||||
return BetterStreamingAssets.FileExists($"YooAssets/{fileName}");
|
||||
}
|
||||
}
|
||||
````
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
**获取资源版本**
|
||||
|
||||
对于联机运行模式,在更新补丁清单之前,需要获取一个资源版本号。
|
||||
对于联机运行模式,在更新补丁清单之前,需要获取一个资源版本。
|
||||
|
||||
该资源版本号,可以通过YooAssets提供的接口来更新,也可以通过HTTP访问游戏服务器来获取。
|
||||
该资源版本可以通过YooAssets提供的接口来更新,也可以通过HTTP访问游戏服务器来获取。
|
||||
|
||||
````c#
|
||||
private IEnumerator UpdateStaticVersion()
|
||||
@@ -15,8 +15,8 @@ private IEnumerator UpdateStaticVersion()
|
||||
if (operation.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
//更新成功
|
||||
int resourceVersion = operation.ResourceVersion;
|
||||
Debug.Log($"Update resource Version : {resourceVersion}");
|
||||
string packageCRC = operation.PackageCRC;
|
||||
Debug.Log($"Update resource Version : {packageCRC}");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -33,7 +33,7 @@ private IEnumerator UpdateStaticVersion()
|
||||
````c#
|
||||
private IEnumerator UpdatePatchManifest()
|
||||
{
|
||||
UpdateManifestOperation operation = YooAssets.UpdateManifestAsync(resourceVersion);
|
||||
UpdateManifestOperation operation = YooAssets.UpdateManifestAsync(packageCRC);
|
||||
yield return operation;
|
||||
|
||||
if (operation.Status == EOperationStatus.Succeed)
|
||||
@@ -120,23 +120,22 @@ private IEnumerator UpdateStaticVersion()
|
||||
{
|
||||
// 如果获取远端资源版本成功,说明当前网络连接并无问题,可以走正常更新流程。
|
||||
......
|
||||
|
||||
|
||||
// 注意:在成功下载所有资源之后,我们需要记录当前最新的资源版本号
|
||||
PlayerPrefs.SetInt("STATIC_VERSION", resourceVersion);
|
||||
PlayerPrefs.SetString("STATIC_VERSION", packageCRC);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 如果获取远端资源版本失败,我们走弱联网更新模式。
|
||||
// 注意:如果从来没有保存过版本信息,则需要从内部读取StaticVersion.bytes文件的版本信息。
|
||||
int staticVersion = PlayerPrefs.GetInt("STATIC_VERSION", -1);
|
||||
if (staticVersion == -1)
|
||||
string packageCRC = PlayerPrefs.GetString("STATIC_VERSION", string.Empty);
|
||||
if (packageCRC == string.Empty)
|
||||
{
|
||||
staticVersion = LoadStaticVersionFromStreamingAssets();
|
||||
PlayerPrefs.SetInt("STATIC_VERSION", staticVersion);
|
||||
packageCRC = LoadStaticVersionFromStreamingAssets();
|
||||
}
|
||||
|
||||
// 在弱联网情况下更新补丁清单
|
||||
UpdateManifestOperation operation2 = YooAssets.WeaklyUpdateManifestAsync(staticVersion);
|
||||
UpdateManifestOperation operation2 = YooAssets.WeaklyUpdateManifestAsync(packageCRC);
|
||||
yield return operation2;
|
||||
if (operation2.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
@@ -151,4 +150,3 @@ private IEnumerator UpdateStaticVersion()
|
||||
}
|
||||
````
|
||||
|
||||
|
||||
|
||||
@@ -53,3 +53,47 @@ var go = Instantiate(obj, transform);
|
||||
go.transform.localPosition = Vector3.zero;
|
||||
go.transform.localScale = Vector3.one;
|
||||
```
|
||||
|
||||
### 分布式构建解决方案
|
||||
|
||||
**1.3.0+版本升级指南**
|
||||
|
||||
在升级之前请导出AssetBundleCollector的配置为XML文件,然后升级YooAssets库。
|
||||
|
||||
首次需要打开AssetBundleCollector窗口,然后导入之前保存的XML文件。
|
||||
|
||||
在运行游戏之前,请保证资源包可以构建成功!
|
||||
|
||||
```c#
|
||||
public static YooAssetPackage AssetPackage;
|
||||
|
||||
IEnumerator Start()
|
||||
{
|
||||
// 初始化YooAssets资源系统(必须代码)
|
||||
YooAssets.Initialize();
|
||||
|
||||
// 创建资源包实例
|
||||
AssetPackage = YooAssets.CreateAssetPackage("DefaultPackage");
|
||||
|
||||
// 初始化资源包
|
||||
......
|
||||
yield return AssetPackage.InitializeAsync(createParameters);
|
||||
|
||||
// 更新资源包版本
|
||||
......
|
||||
var operation = AssetPackage.UpdateManifestAsync(packageCRC);
|
||||
yield return operation;
|
||||
|
||||
// 下载更新文件
|
||||
var downloader = AssetPackage.CreatePatchDownloader(downloadingMaxNum, failedTryAgain);
|
||||
downloader.BeginDownload();
|
||||
yield return downloader;
|
||||
|
||||
// 加载资源对象
|
||||
var assetHandle = AssetPackage.LoadAssetAsync("Assets/GameRes/npc.prefab");
|
||||
yield return assetHandle;
|
||||
......
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# 全局配置
|
||||
|
||||

|
||||

|
||||
|
||||
通过右键创建配置文件(Project窗体内右键 -> Create -> YooAsset -> Create Setting)
|
||||
|
||||
@@ -11,5 +11,4 @@
|
||||
- **Asset Bundle File Variant** : AssetBundle资源包后缀名
|
||||
- **Raw File Variant** : 原生资源包后缀名
|
||||
- **Patch Manifest File Name** : 补丁清单文件名称
|
||||
- **Unity Manifest File Name** : Unity构建的清单名称
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 63 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 52 KiB |
BIN
Docs/Image/AssetCollector-img1.png
Normal file
|
After Width: | Height: | Size: 129 KiB |
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 77 KiB |
|
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 86 KiB |
|
Before Width: | Height: | Size: 96 KiB |
|
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 96 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 78 KiB |
|
Before Width: | Height: | Size: 27 KiB |
BIN
Docs/Image/Settings-img1.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
@@ -14,5 +14,6 @@
|
||||
|
||||

|
||||
|
||||
1. Basic Sample在导入完成后,需要移动目录。
|
||||
1. Basic Sample在导入完成后,打开YooAsset->AssetBundle Collector窗口。
|
||||
1. 点击修复按钮,然后点击Save按钮保存配置,最后关闭窗口。
|
||||
3. 找到Boot.scene场景启动游戏。
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"com.unity.ide.visualstudio": "2.0.16",
|
||||
"com.unity.ide.vscode": "1.2.5",
|
||||
"com.unity.scriptablebuildpipeline": "1.20.2",
|
||||
"com.unity.test-framework": "1.1.31",
|
||||
"com.unity.ugui": "1.0.0",
|
||||
"com.unity.modules.ai": "1.0.0",
|
||||
"com.unity.modules.androidjni": "1.0.0",
|
||||
"com.unity.modules.animation": "1.0.0",
|
||||
"com.unity.modules.assetbundle": "1.0.0",
|
||||
"com.unity.modules.audio": "1.0.0",
|
||||
"com.unity.modules.cloth": "1.0.0",
|
||||
"com.unity.modules.director": "1.0.0",
|
||||
"com.unity.modules.imageconversion": "1.0.0",
|
||||
"com.unity.modules.imgui": "1.0.0",
|
||||
"com.unity.modules.jsonserialize": "1.0.0",
|
||||
"com.unity.modules.particlesystem": "1.0.0",
|
||||
"com.unity.modules.physics": "1.0.0",
|
||||
"com.unity.modules.physics2d": "1.0.0",
|
||||
"com.unity.modules.screencapture": "1.0.0",
|
||||
"com.unity.modules.terrain": "1.0.0",
|
||||
"com.unity.modules.terrainphysics": "1.0.0",
|
||||
"com.unity.modules.tilemap": "1.0.0",
|
||||
"com.unity.modules.ui": "1.0.0",
|
||||
"com.unity.modules.uielements": "1.0.0",
|
||||
"com.unity.modules.umbra": "1.0.0",
|
||||
"com.unity.modules.unityanalytics": "1.0.0",
|
||||
"com.unity.modules.unitywebrequest": "1.0.0",
|
||||
"com.unity.modules.unitywebrequestassetbundle": "1.0.0",
|
||||
"com.unity.modules.unitywebrequestaudio": "1.0.0",
|
||||
"com.unity.modules.unitywebrequesttexture": "1.0.0",
|
||||
"com.unity.modules.unitywebrequestwww": "1.0.0",
|
||||
"com.unity.modules.vehicles": "1.0.0",
|
||||
"com.unity.modules.video": "1.0.0",
|
||||
"com.unity.modules.vr": "1.0.0",
|
||||
"com.unity.modules.wind": "1.0.0",
|
||||
"com.unity.modules.xr": "1.0.0"
|
||||
}
|
||||
}
|
||||
@@ -1,296 +0,0 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"com.unity.ext.nunit": {
|
||||
"version": "1.0.6",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.ide.visualstudio": {
|
||||
"version": "2.0.16",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.test-framework": "1.1.9"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.ide.vscode": {
|
||||
"version": "1.2.5",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.scriptablebuildpipeline": {
|
||||
"version": "1.20.2",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.test-framework": {
|
||||
"version": "1.1.31",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.ext.nunit": "1.0.6",
|
||||
"com.unity.modules.imgui": "1.0.0",
|
||||
"com.unity.modules.jsonserialize": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.ugui": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.ui": "1.0.0",
|
||||
"com.unity.modules.imgui": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.ai": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.androidjni": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.animation": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.assetbundle": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.audio": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.cloth": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.physics": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.director": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.audio": "1.0.0",
|
||||
"com.unity.modules.animation": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.imageconversion": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.imgui": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.jsonserialize": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.particlesystem": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.physics": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.physics2d": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.screencapture": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.imageconversion": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.subsystems": {
|
||||
"version": "1.0.0",
|
||||
"depth": 1,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.jsonserialize": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.terrain": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.terrainphysics": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.physics": "1.0.0",
|
||||
"com.unity.modules.terrain": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.tilemap": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.physics2d": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.ui": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.uielements": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.imgui": "1.0.0",
|
||||
"com.unity.modules.jsonserialize": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.umbra": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.unityanalytics": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.unitywebrequest": "1.0.0",
|
||||
"com.unity.modules.jsonserialize": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.unitywebrequest": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.unitywebrequestassetbundle": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.assetbundle": "1.0.0",
|
||||
"com.unity.modules.unitywebrequest": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.unitywebrequestaudio": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.unitywebrequest": "1.0.0",
|
||||
"com.unity.modules.audio": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.unitywebrequesttexture": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.unitywebrequest": "1.0.0",
|
||||
"com.unity.modules.imageconversion": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.unitywebrequestwww": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.unitywebrequest": "1.0.0",
|
||||
"com.unity.modules.unitywebrequestassetbundle": "1.0.0",
|
||||
"com.unity.modules.unitywebrequestaudio": "1.0.0",
|
||||
"com.unity.modules.audio": "1.0.0",
|
||||
"com.unity.modules.assetbundle": "1.0.0",
|
||||
"com.unity.modules.imageconversion": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.vehicles": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.physics": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.video": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.audio": "1.0.0",
|
||||
"com.unity.modules.ui": "1.0.0",
|
||||
"com.unity.modules.unitywebrequest": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.vr": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.jsonserialize": "1.0.0",
|
||||
"com.unity.modules.physics": "1.0.0",
|
||||
"com.unity.modules.xr": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.wind": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.xr": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.physics": "1.0.0",
|
||||
"com.unity.modules.jsonserialize": "1.0.0",
|
||||
"com.unity.modules.subsystems": "1.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!11 &1
|
||||
AudioManager:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Volume: 1
|
||||
Rolloff Scale: 1
|
||||
Doppler Factor: 1
|
||||
Default Speaker Mode: 2
|
||||
m_SampleRate: 0
|
||||
m_DSPBufferSize: 1024
|
||||
m_VirtualVoiceCount: 512
|
||||
m_RealVoiceCount: 32
|
||||
m_EnableOutputSuspension: 1
|
||||
m_SpatializerPlugin:
|
||||
m_AmbisonicDecoderPlugin:
|
||||
m_DisableAudio: 0
|
||||
m_VirtualizeEffects: 1
|
||||
m_RequestedDSPBufferSize: 0
|
||||
@@ -1,19 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1200 &1
|
||||
AutoStreamingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
mSearchMode: 7
|
||||
mCustomSearchFile:
|
||||
mTextures: []
|
||||
mAudios: []
|
||||
mMeshes: []
|
||||
mScenes: []
|
||||
mConfigCCD:
|
||||
useCCD: 0
|
||||
cosKey:
|
||||
projectGuid:
|
||||
bucketUuid:
|
||||
bucketName:
|
||||
badgeName:
|
||||
@@ -1,6 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!236 &1
|
||||
ClusterInputManager:
|
||||
m_ObjectHideFlags: 0
|
||||
m_Inputs: []
|
||||
@@ -1,36 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!55 &1
|
||||
PhysicsManager:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 13
|
||||
m_Gravity: {x: 0, y: -9.81, z: 0}
|
||||
m_DefaultMaterial: {fileID: 0}
|
||||
m_BounceThreshold: 2
|
||||
m_SleepThreshold: 0.005
|
||||
m_DefaultContactOffset: 0.01
|
||||
m_DefaultSolverIterations: 6
|
||||
m_DefaultSolverVelocityIterations: 1
|
||||
m_QueriesHitBackfaces: 0
|
||||
m_QueriesHitTriggers: 1
|
||||
m_EnableAdaptiveForce: 0
|
||||
m_ClothInterCollisionDistance: 0.1
|
||||
m_ClothInterCollisionStiffness: 0.2
|
||||
m_ContactsGeneration: 1
|
||||
m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
m_AutoSimulation: 1
|
||||
m_AutoSyncTransforms: 0
|
||||
m_ReuseCollisionCallbacks: 0
|
||||
m_ClothInterCollisionSettingsToggle: 0
|
||||
m_ClothGravity: {x: 0, y: -9.81, z: 0}
|
||||
m_ContactPairsMode: 0
|
||||
m_BroadphaseType: 0
|
||||
m_WorldBounds:
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
m_Extent: {x: 250, y: 250, z: 250}
|
||||
m_WorldSubdivisions: 8
|
||||
m_FrictionType: 0
|
||||
m_EnableEnhancedDeterminism: 0
|
||||
m_EnableUnifiedHeightmaps: 1
|
||||
m_SolverType: 0
|
||||
m_DefaultMaxAngularSpeed: 50
|
||||
@@ -1,8 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1045 &1
|
||||
EditorBuildSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Scenes: []
|
||||
m_configObjects: {}
|
||||
@@ -1,35 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!159 &1
|
||||
EditorSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 9
|
||||
m_ExternalVersionControlSupport: Visible Meta Files
|
||||
m_SerializationMode: 2
|
||||
m_LineEndingsForNewScripts: 2
|
||||
m_DefaultBehaviorMode: 0
|
||||
m_PrefabRegularEnvironment: {fileID: 0}
|
||||
m_PrefabUIEnvironment: {fileID: 0}
|
||||
m_SpritePackerMode: 0
|
||||
m_SpritePackerPaddingPower: 1
|
||||
m_EtcTextureCompressorBehavior: 1
|
||||
m_EtcTextureFastCompressor: 1
|
||||
m_EtcTextureNormalCompressor: 2
|
||||
m_EtcTextureBestCompressor: 4
|
||||
m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;asmref;rsp
|
||||
m_ProjectGenerationRootNamespace:
|
||||
m_CollabEditorSettings:
|
||||
inProgressEnabled: 1
|
||||
m_EnableTextureStreamingInEditMode: 1
|
||||
m_EnableTextureStreamingInPlayMode: 1
|
||||
m_AsyncShaderCompilation: 1
|
||||
m_EnterPlayModeOptionsEnabled: 0
|
||||
m_EnterPlayModeOptions: 3
|
||||
m_ShowLightmapResolutionOverlay: 1
|
||||
m_UseLegacyProbeSampleCount: 0
|
||||
m_AssetPipelineMode: 1
|
||||
m_CacheServerMode: 0
|
||||
m_CacheServerEndpoint:
|
||||
m_CacheServerNamespacePrefix: default
|
||||
m_CacheServerEnableDownload: 1
|
||||
m_CacheServerEnableUpload: 1
|
||||
@@ -1,64 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!30 &1
|
||||
GraphicsSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 13
|
||||
m_Deferred:
|
||||
m_Mode: 1
|
||||
m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_DeferredReflections:
|
||||
m_Mode: 1
|
||||
m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ScreenSpaceShadows:
|
||||
m_Mode: 1
|
||||
m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_LegacyDeferred:
|
||||
m_Mode: 1
|
||||
m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_DepthNormals:
|
||||
m_Mode: 1
|
||||
m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_MotionVectors:
|
||||
m_Mode: 1
|
||||
m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_LightHalo:
|
||||
m_Mode: 1
|
||||
m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_LensFlare:
|
||||
m_Mode: 1
|
||||
m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_AlwaysIncludedShaders:
|
||||
- {fileID: 7, guid: 0000000000000000f000000000000000, type: 0}
|
||||
- {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0}
|
||||
- {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0}
|
||||
- {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0}
|
||||
- {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0}
|
||||
- {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
|
||||
- {fileID: 10783, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_PreloadedShaders: []
|
||||
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
|
||||
type: 0}
|
||||
m_CustomRenderPipeline: {fileID: 0}
|
||||
m_TransparencySortMode: 0
|
||||
m_TransparencySortAxis: {x: 0, y: 0, z: 1}
|
||||
m_DefaultRenderingPath: 1
|
||||
m_DefaultMobileRenderingPath: 1
|
||||
m_TierSettings: []
|
||||
m_LightmapStripping: 0
|
||||
m_FogStripping: 0
|
||||
m_InstancingStripping: 0
|
||||
m_LightmapKeepPlain: 1
|
||||
m_LightmapKeepDirCombined: 1
|
||||
m_LightmapKeepDynamicPlain: 1
|
||||
m_LightmapKeepDynamicDirCombined: 1
|
||||
m_LightmapKeepShadowMask: 1
|
||||
m_LightmapKeepSubtractive: 1
|
||||
m_FogKeepLinear: 1
|
||||
m_FogKeepExp: 1
|
||||
m_FogKeepExp2: 1
|
||||
m_AlbedoSwatchInfos: []
|
||||
m_LightsUseLinearIntensity: 0
|
||||
m_LightsUseColorTemperature: 0
|
||||
m_LogWhenShaderIsCompiled: 0
|
||||
m_AllowEnlightenSupportForUpgradedProject: 0
|
||||
@@ -1,295 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!13 &1
|
||||
InputManager:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Axes:
|
||||
- serializedVersion: 3
|
||||
m_Name: Horizontal
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton: left
|
||||
positiveButton: right
|
||||
altNegativeButton: a
|
||||
altPositiveButton: d
|
||||
gravity: 3
|
||||
dead: 0.001
|
||||
sensitivity: 3
|
||||
snap: 1
|
||||
invert: 0
|
||||
type: 0
|
||||
axis: 0
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Vertical
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton: down
|
||||
positiveButton: up
|
||||
altNegativeButton: s
|
||||
altPositiveButton: w
|
||||
gravity: 3
|
||||
dead: 0.001
|
||||
sensitivity: 3
|
||||
snap: 1
|
||||
invert: 0
|
||||
type: 0
|
||||
axis: 0
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Fire1
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton: left ctrl
|
||||
altNegativeButton:
|
||||
altPositiveButton: mouse 0
|
||||
gravity: 1000
|
||||
dead: 0.001
|
||||
sensitivity: 1000
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 0
|
||||
axis: 0
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Fire2
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton: left alt
|
||||
altNegativeButton:
|
||||
altPositiveButton: mouse 1
|
||||
gravity: 1000
|
||||
dead: 0.001
|
||||
sensitivity: 1000
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 0
|
||||
axis: 0
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Fire3
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton: left shift
|
||||
altNegativeButton:
|
||||
altPositiveButton: mouse 2
|
||||
gravity: 1000
|
||||
dead: 0.001
|
||||
sensitivity: 1000
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 0
|
||||
axis: 0
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Jump
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton: space
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 1000
|
||||
dead: 0.001
|
||||
sensitivity: 1000
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 0
|
||||
axis: 0
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Mouse X
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 0.1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 1
|
||||
axis: 0
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Mouse Y
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 0.1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 1
|
||||
axis: 1
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Mouse ScrollWheel
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0
|
||||
sensitivity: 0.1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 1
|
||||
axis: 2
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Horizontal
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0.19
|
||||
sensitivity: 1
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 2
|
||||
axis: 0
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Vertical
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton:
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 0
|
||||
dead: 0.19
|
||||
sensitivity: 1
|
||||
snap: 0
|
||||
invert: 1
|
||||
type: 2
|
||||
axis: 1
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Fire1
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton: joystick button 0
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 1000
|
||||
dead: 0.001
|
||||
sensitivity: 1000
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 0
|
||||
axis: 0
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Fire2
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton: joystick button 1
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 1000
|
||||
dead: 0.001
|
||||
sensitivity: 1000
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 0
|
||||
axis: 0
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Fire3
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton: joystick button 2
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 1000
|
||||
dead: 0.001
|
||||
sensitivity: 1000
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 0
|
||||
axis: 0
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Jump
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton: joystick button 3
|
||||
altNegativeButton:
|
||||
altPositiveButton:
|
||||
gravity: 1000
|
||||
dead: 0.001
|
||||
sensitivity: 1000
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 0
|
||||
axis: 0
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Submit
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton: return
|
||||
altNegativeButton:
|
||||
altPositiveButton: joystick button 0
|
||||
gravity: 1000
|
||||
dead: 0.001
|
||||
sensitivity: 1000
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 0
|
||||
axis: 0
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Submit
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton: enter
|
||||
altNegativeButton:
|
||||
altPositiveButton: space
|
||||
gravity: 1000
|
||||
dead: 0.001
|
||||
sensitivity: 1000
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 0
|
||||
axis: 0
|
||||
joyNum: 0
|
||||
- serializedVersion: 3
|
||||
m_Name: Cancel
|
||||
descriptiveName:
|
||||
descriptiveNegativeName:
|
||||
negativeButton:
|
||||
positiveButton: escape
|
||||
altNegativeButton:
|
||||
altPositiveButton: joystick button 1
|
||||
gravity: 1000
|
||||
dead: 0.001
|
||||
sensitivity: 1000
|
||||
snap: 0
|
||||
invert: 0
|
||||
type: 0
|
||||
axis: 0
|
||||
joyNum: 0
|
||||
@@ -1,91 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!126 &1
|
||||
NavMeshProjectSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
areas:
|
||||
- name: Walkable
|
||||
cost: 1
|
||||
- name: Not Walkable
|
||||
cost: 1
|
||||
- name: Jump
|
||||
cost: 2
|
||||
- name:
|
||||
cost: 1
|
||||
- name:
|
||||
cost: 1
|
||||
- name:
|
||||
cost: 1
|
||||
- name:
|
||||
cost: 1
|
||||
- name:
|
||||
cost: 1
|
||||
- name:
|
||||
cost: 1
|
||||
- name:
|
||||
cost: 1
|
||||
- name:
|
||||
cost: 1
|
||||
- name:
|
||||
cost: 1
|
||||
- name:
|
||||
cost: 1
|
||||
- name:
|
||||
cost: 1
|
||||
- name:
|
||||
cost: 1
|
||||
- name:
|
||||
cost: 1
|
||||
- name:
|
||||
cost: 1
|
||||
- name:
|
||||
cost: 1
|
||||
- name:
|
||||
cost: 1
|
||||
- name:
|
||||
cost: 1
|
||||
- name:
|
||||
cost: 1
|
||||
- name:
|
||||
cost: 1
|
||||
- name:
|
||||
cost: 1
|
||||
- name:
|
||||
cost: 1
|
||||
- name:
|
||||
cost: 1
|
||||
- name:
|
||||
cost: 1
|
||||
- name:
|
||||
cost: 1
|
||||
- name:
|
||||
cost: 1
|
||||
- name:
|
||||
cost: 1
|
||||
- name:
|
||||
cost: 1
|
||||
- name:
|
||||
cost: 1
|
||||
- name:
|
||||
cost: 1
|
||||
m_LastAgentTypeID: -887442657
|
||||
m_Settings:
|
||||
- serializedVersion: 2
|
||||
agentTypeID: 0
|
||||
agentRadius: 0.5
|
||||
agentHeight: 2
|
||||
agentSlope: 45
|
||||
agentClimb: 0.75
|
||||
ledgeDropHeight: 0
|
||||
maxJumpAcrossDistance: 0
|
||||
minRegionArea: 2
|
||||
manualCellSize: 0
|
||||
cellSize: 0.16666667
|
||||
manualTileSize: 0
|
||||
tileSize: 256
|
||||
accuratePlacement: 0
|
||||
debug:
|
||||
m_Flags: 0
|
||||
m_SettingNames:
|
||||
- Humanoid
|
||||
@@ -1,38 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &1
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 61
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_ScopedRegistriesSettingsExpanded: 1
|
||||
oneTimeWarningShown: 0
|
||||
m_Registries:
|
||||
- m_Id: main
|
||||
m_Name:
|
||||
m_Url: https://packages.unity.cn
|
||||
m_Scopes: []
|
||||
m_IsDefault: 1
|
||||
m_UserSelectedRegistryName:
|
||||
m_UserAddingNewScopedRegistry: 0
|
||||
m_RegistryInfoDraft:
|
||||
m_ErrorMessage:
|
||||
m_Original:
|
||||
m_Id:
|
||||
m_Name:
|
||||
m_Url:
|
||||
m_Scopes: []
|
||||
m_IsDefault: 0
|
||||
m_Modified: 0
|
||||
m_Name:
|
||||
m_Url:
|
||||
m_Scopes:
|
||||
-
|
||||
m_SelectedScopeIndex: 0
|
||||
@@ -1,56 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!19 &1
|
||||
Physics2DSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 4
|
||||
m_Gravity: {x: 0, y: -9.81}
|
||||
m_DefaultMaterial: {fileID: 0}
|
||||
m_VelocityIterations: 8
|
||||
m_PositionIterations: 3
|
||||
m_VelocityThreshold: 1
|
||||
m_MaxLinearCorrection: 0.2
|
||||
m_MaxAngularCorrection: 8
|
||||
m_MaxTranslationSpeed: 100
|
||||
m_MaxRotationSpeed: 360
|
||||
m_BaumgarteScale: 0.2
|
||||
m_BaumgarteTimeOfImpactScale: 0.75
|
||||
m_TimeToSleep: 0.5
|
||||
m_LinearSleepTolerance: 0.01
|
||||
m_AngularSleepTolerance: 2
|
||||
m_DefaultContactOffset: 0.01
|
||||
m_JobOptions:
|
||||
serializedVersion: 2
|
||||
useMultithreading: 0
|
||||
useConsistencySorting: 0
|
||||
m_InterpolationPosesPerJob: 100
|
||||
m_NewContactsPerJob: 30
|
||||
m_CollideContactsPerJob: 100
|
||||
m_ClearFlagsPerJob: 200
|
||||
m_ClearBodyForcesPerJob: 200
|
||||
m_SyncDiscreteFixturesPerJob: 50
|
||||
m_SyncContinuousFixturesPerJob: 50
|
||||
m_FindNearestContactsPerJob: 100
|
||||
m_UpdateTriggerContactsPerJob: 100
|
||||
m_IslandSolverCostThreshold: 100
|
||||
m_IslandSolverBodyCostScale: 1
|
||||
m_IslandSolverContactCostScale: 10
|
||||
m_IslandSolverJointCostScale: 10
|
||||
m_IslandSolverBodiesPerJob: 50
|
||||
m_IslandSolverContactsPerJob: 50
|
||||
m_AutoSimulation: 1
|
||||
m_QueriesHitTriggers: 1
|
||||
m_QueriesStartInColliders: 1
|
||||
m_CallbacksOnDisable: 1
|
||||
m_ReuseCollisionCallbacks: 0
|
||||
m_AutoSyncTransforms: 0
|
||||
m_AlwaysShowColliders: 0
|
||||
m_ShowColliderSleep: 1
|
||||
m_ShowColliderContacts: 0
|
||||
m_ShowColliderAABB: 0
|
||||
m_ContactArrowScale: 0.2
|
||||
m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412}
|
||||
m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432}
|
||||
m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745}
|
||||
m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804}
|
||||
m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
@@ -1,7 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1386491679 &1
|
||||
PresetManager:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_DefaultPresets: {}
|
||||