parent
9fbce6a726
commit
ea28d3e6e1
|
@ -117,11 +117,11 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 从输出目录加载补丁清单文件
|
/// 加载补丁清单文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static PatchManifest LoadPatchManifestFile(string fileDirectory)
|
internal static PatchManifest LoadPatchManifestFile(string fileDirectory, int resourceVersion)
|
||||||
{
|
{
|
||||||
string filePath = $"{fileDirectory}/{YooAssetSettingsData.Setting.PatchManifestFileName}";
|
string filePath = $"{fileDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(resourceVersion)}";
|
||||||
if (File.Exists(filePath) == false)
|
if (File.Exists(filePath) == false)
|
||||||
{
|
{
|
||||||
throw new System.Exception($"Not found patch manifest file : {filePath}");
|
throw new System.Exception($"Not found patch manifest file : {filePath}");
|
||||||
|
@ -130,5 +130,16 @@ namespace YooAsset.Editor
|
||||||
string jsonData = FileUtility.ReadFile(filePath);
|
string jsonData = FileUtility.ReadFile(filePath);
|
||||||
return PatchManifest.Deserialize(jsonData);
|
return PatchManifest.Deserialize(jsonData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取旧的补丁清单
|
||||||
|
/// </summary>
|
||||||
|
internal static PatchManifest GetOldPatchManifest(string pipelineOutputDirectory)
|
||||||
|
{
|
||||||
|
string staticVersionFilePath = $"{pipelineOutputDirectory}/{YooAssetSettings.VersionFileName}";
|
||||||
|
string staticVersionContent = FileUtility.ReadFile(staticVersionFilePath);
|
||||||
|
int staticVersion = int.Parse(staticVersionContent);
|
||||||
|
return LoadPatchManifestFile(pipelineOutputDirectory, staticVersion);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -27,11 +27,6 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long SizeBytes;
|
public long SizeBytes;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 文件版本
|
|
||||||
/// </summary>
|
|
||||||
public int Version;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tags
|
/// Tags
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -15,21 +15,20 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
// 注意:我们只有在强制重建的时候才会拷贝
|
// 注意:我们只有在强制重建的时候才会拷贝
|
||||||
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
var buildParameters = context.GetContextObject<AssetBundleBuilder.BuildParametersContext>();
|
||||||
if(buildParameters.Parameters.ForceRebuild)
|
if (buildParameters.Parameters.ForceRebuild)
|
||||||
{
|
{
|
||||||
// 清空流目录
|
// 清空流目录
|
||||||
AssetBundleBuilderHelper.ClearStreamingAssetsFolder();
|
AssetBundleBuilderHelper.ClearStreamingAssetsFolder();
|
||||||
|
|
||||||
// 拷贝内置文件
|
// 拷贝内置文件
|
||||||
var pipelineOutputDirectory = buildParameters.PipelineOutputDirectory;
|
CopyBuildinFilesToStreaming(buildParameters.PipelineOutputDirectory, buildParameters.Parameters.BuildVersion);
|
||||||
CopyBuildinFilesToStreaming(pipelineOutputDirectory);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CopyBuildinFilesToStreaming(string pipelineOutputDirectory)
|
private void CopyBuildinFilesToStreaming(string pipelineOutputDirectory, int buildVersion)
|
||||||
{
|
{
|
||||||
// 加载补丁清单
|
// 加载补丁清单
|
||||||
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(pipelineOutputDirectory);
|
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(pipelineOutputDirectory, buildVersion);
|
||||||
|
|
||||||
// 拷贝文件列表
|
// 拷贝文件列表
|
||||||
foreach (var patchBundle in patchManifest.BundleList)
|
foreach (var patchBundle in patchManifest.BundleList)
|
||||||
|
@ -45,15 +44,22 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
// 拷贝清单文件
|
// 拷贝清单文件
|
||||||
{
|
{
|
||||||
string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettingsData.Setting.PatchManifestFileName}";
|
string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(buildVersion)}";
|
||||||
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{YooAssetSettingsData.Setting.PatchManifestFileName}";
|
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{YooAssetSettingsData.GetPatchManifestFileName(buildVersion)}";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拷贝清单哈希文件
|
// 拷贝清单哈希文件
|
||||||
{
|
{
|
||||||
string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettingsData.Setting.PatchManifestHashFileName}";
|
string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestHashFileName(buildVersion)}";
|
||||||
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{YooAssetSettingsData.Setting.PatchManifestHashFileName}";
|
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{YooAssetSettingsData.GetPatchManifestHashFileName(buildVersion)}";
|
||||||
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 拷贝静态版本文件
|
||||||
|
{
|
||||||
|
string sourcePath = $"{pipelineOutputDirectory}/{YooAssetSettings.VersionFileName}";
|
||||||
|
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsFolderPath()}/{YooAssetSettings.VersionFileName}";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@ namespace YooAsset.Editor
|
||||||
private void CreatePatchManifestFile(AssetBundleBuilder.BuildParametersContext buildParameters,
|
private void CreatePatchManifestFile(AssetBundleBuilder.BuildParametersContext buildParameters,
|
||||||
BuildMapContext buildMapContext, TaskEncryption.EncryptionContext encryptionContext)
|
BuildMapContext buildMapContext, TaskEncryption.EncryptionContext encryptionContext)
|
||||||
{
|
{
|
||||||
|
int resourceVersion = buildParameters.Parameters.BuildVersion;
|
||||||
|
|
||||||
// 创建新补丁清单
|
// 创建新补丁清单
|
||||||
PatchManifest patchManifest = new PatchManifest();
|
PatchManifest patchManifest = new PatchManifest();
|
||||||
patchManifest.ResourceVersion = buildParameters.Parameters.BuildVersion;
|
patchManifest.ResourceVersion = buildParameters.Parameters.BuildVersion;
|
||||||
|
@ -32,15 +34,21 @@ namespace YooAsset.Editor
|
||||||
patchManifest.AssetList = GetAllPatchAsset(buildMapContext, patchManifest);
|
patchManifest.AssetList = GetAllPatchAsset(buildMapContext, patchManifest);
|
||||||
|
|
||||||
// 创建补丁清单文件
|
// 创建补丁清单文件
|
||||||
string manifestFilePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.Setting.PatchManifestFileName}";
|
string manifestFilePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(resourceVersion)}";
|
||||||
UnityEngine.Debug.Log($"创建补丁清单文件:{manifestFilePath}");
|
UnityEngine.Debug.Log($"创建补丁清单文件:{manifestFilePath}");
|
||||||
PatchManifest.Serialize(manifestFilePath, patchManifest);
|
PatchManifest.Serialize(manifestFilePath, patchManifest);
|
||||||
|
|
||||||
// 创建补丁清单哈希文件
|
// 创建补丁清单哈希文件
|
||||||
string manifestHashFilePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.Setting.PatchManifestHashFileName}";
|
string manifestHashFilePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestHashFileName(resourceVersion)}";
|
||||||
string manifestHash = HashUtility.FileMD5(manifestFilePath);
|
string manifestHash = HashUtility.FileMD5(manifestFilePath);
|
||||||
UnityEngine.Debug.Log($"创建补丁清单哈希文件:{manifestHashFilePath}");
|
UnityEngine.Debug.Log($"创建补丁清单哈希文件:{manifestHashFilePath}");
|
||||||
FileUtility.CreateFile(manifestHashFilePath, manifestHash);
|
FileUtility.CreateFile(manifestHashFilePath, manifestHash);
|
||||||
|
|
||||||
|
// 创建静态版本文件
|
||||||
|
string staticVersionFilePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettings.VersionFileName}";
|
||||||
|
string staticVersion = resourceVersion.ToString();
|
||||||
|
UnityEngine.Debug.Log($"创建静态版本文件:{staticVersionFilePath}");
|
||||||
|
FileUtility.CreateFile(staticVersionFilePath, staticVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -54,19 +62,12 @@ namespace YooAsset.Editor
|
||||||
// 内置标记列表
|
// 内置标记列表
|
||||||
List<string> buildinTags = buildParameters.Parameters.GetBuildinTags();
|
List<string> buildinTags = buildParameters.Parameters.GetBuildinTags();
|
||||||
|
|
||||||
// 加载旧补丁清单
|
|
||||||
PatchManifest oldPatchManifest = null;
|
|
||||||
if (buildParameters.Parameters.ForceRebuild == false)
|
|
||||||
{
|
|
||||||
oldPatchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
foreach (var bundleInfo in buildMapContext.BundleInfos)
|
||||||
{
|
{
|
||||||
var bundleName = bundleInfo.BundleName;
|
var bundleName = bundleInfo.BundleName;
|
||||||
string filePath = $"{buildParameters.PipelineOutputDirectory}/{bundleName}";
|
string filePath = $"{buildParameters.PipelineOutputDirectory}/{bundleName}";
|
||||||
string hash = HashUtility.FileMD5(filePath);
|
string hash = HashUtility.FileMD5(filePath);
|
||||||
string crc = HashUtility.FileCRC32(filePath);
|
string crc32 = HashUtility.FileCRC32(filePath);
|
||||||
long size = FileUtility.GetFileSize(filePath);
|
long size = FileUtility.GetFileSize(filePath);
|
||||||
int version = buildParameters.Parameters.BuildVersion;
|
int version = buildParameters.Parameters.BuildVersion;
|
||||||
string[] tags = buildMapContext.GetAssetTags(bundleName);
|
string[] tags = buildMapContext.GetAssetTags(bundleName);
|
||||||
|
@ -80,14 +81,7 @@ namespace YooAsset.Editor
|
||||||
hash += bundleInfo.GetAppendExtension();
|
hash += bundleInfo.GetAppendExtension();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 注意:如果文件没有变化使用旧版本号
|
PatchBundle patchBundle = new PatchBundle(bundleName, hash, crc32, size, tags);
|
||||||
if (oldPatchManifest != null && oldPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle value))
|
|
||||||
{
|
|
||||||
if (value.Hash == hash)
|
|
||||||
version = value.Version;
|
|
||||||
}
|
|
||||||
|
|
||||||
PatchBundle patchBundle = new PatchBundle(bundleName, hash, crc, size, version, tags);
|
|
||||||
patchBundle.SetFlagsValue(isEncrypted, isBuildin, isRawFile);
|
patchBundle.SetFlagsValue(isEncrypted, isBuildin, isRawFile);
|
||||||
result.Add(patchBundle);
|
result.Add(patchBundle);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,31 +19,40 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void CopyPatchFiles(AssetBundleBuilder.BuildParametersContext buildParameters)
|
private void CopyPatchFiles(AssetBundleBuilder.BuildParametersContext buildParameters)
|
||||||
{
|
{
|
||||||
|
int resourceVersion = buildParameters.Parameters.BuildVersion;
|
||||||
string packageDirectory = buildParameters.GetPackageDirectory();
|
string packageDirectory = buildParameters.GetPackageDirectory();
|
||||||
UnityEngine.Debug.Log($"开始拷贝补丁文件到补丁包目录:{packageDirectory}");
|
UnityEngine.Debug.Log($"准备开始拷贝补丁文件到补丁包目录:{packageDirectory}");
|
||||||
|
|
||||||
// 拷贝Report文件
|
// 拷贝Report文件
|
||||||
{
|
{
|
||||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettings.ReportFileName}";
|
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettings.ReportFileName}";
|
||||||
string destPath = $"{packageDirectory}/{YooAssetSettings.ReportFileName}";
|
string destPath = $"{packageDirectory}/{YooAssetSettings.ReportFileName}";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
UnityEngine.Debug.Log($"拷贝Report文件到:{destPath}");
|
UnityEngine.Debug.Log($"拷贝构建报告文件到:{destPath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拷贝PatchManifest文件
|
// 拷贝补丁清单文件
|
||||||
{
|
{
|
||||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.Setting.PatchManifestFileName}";
|
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(resourceVersion)}";
|
||||||
string destPath = $"{packageDirectory}/{YooAssetSettingsData.Setting.PatchManifestFileName}";
|
string destPath = $"{packageDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(resourceVersion)}";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
UnityEngine.Debug.Log($"拷贝PatchManifest文件到:{destPath}");
|
UnityEngine.Debug.Log($"拷贝补丁清单文件到:{destPath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拷贝PatchManifest哈希文件
|
// 拷贝补丁清单哈希文件
|
||||||
{
|
{
|
||||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.Setting.PatchManifestHashFileName}";
|
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettingsData.GetPatchManifestHashFileName(resourceVersion)}";
|
||||||
string destPath = $"{packageDirectory}/{YooAssetSettingsData.Setting.PatchManifestHashFileName}";
|
string destPath = $"{packageDirectory}/{YooAssetSettingsData.GetPatchManifestHashFileName(resourceVersion)}";
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
UnityEngine.Debug.Log($"拷贝PatchManifest哈希文件到:{destPath}");
|
UnityEngine.Debug.Log($"拷贝补丁清单哈希文件到:{destPath}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 拷贝静态版本文件
|
||||||
|
{
|
||||||
|
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{YooAssetSettings.VersionFileName}";
|
||||||
|
string destPath = $"{packageDirectory}/{YooAssetSettings.VersionFileName}";
|
||||||
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
|
UnityEngine.Debug.Log($"拷贝静态版本文件到:{destPath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拷贝UnityManifest序列化文件
|
// 拷贝UnityManifest序列化文件
|
||||||
|
@ -62,20 +71,16 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
|
|
||||||
// 拷贝所有补丁文件
|
// 拷贝所有补丁文件
|
||||||
// 注意:拷贝的补丁文件都是需要玩家热更新的文件
|
|
||||||
int progressValue = 0;
|
int progressValue = 0;
|
||||||
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory);
|
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory, buildParameters.Parameters.BuildVersion);
|
||||||
int patchFileTotalCount = patchManifest.BundleList.Count;
|
int patchFileTotalCount = patchManifest.BundleList.Count;
|
||||||
foreach (var patchBundle in patchManifest.BundleList)
|
foreach (var patchBundle in patchManifest.BundleList)
|
||||||
{
|
{
|
||||||
if (patchBundle.Version == buildParameters.Parameters.BuildVersion)
|
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{patchBundle.BundleName}";
|
||||||
{
|
string destPath = $"{packageDirectory}/{patchBundle.Hash}";
|
||||||
string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{patchBundle.BundleName}";
|
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||||
string destPath = $"{packageDirectory}/{patchBundle.Hash}";
|
UnityEngine.Debug.Log($"拷贝补丁文件到补丁包:{patchBundle.BundleName}");
|
||||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
EditorTools.DisplayProgressBar("拷贝补丁文件", ++progressValue, patchFileTotalCount);
|
||||||
UnityEngine.Debug.Log($"拷贝补丁文件到补丁包:{patchBundle.BundleName}");
|
|
||||||
EditorTools.DisplayProgressBar("拷贝补丁文件", ++progressValue, patchFileTotalCount);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
EditorTools.ClearProgressBar();
|
EditorTools.ClearProgressBar();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
private void CreateReportFile(AssetBundleBuilder.BuildParametersContext buildParameters, BuildMapContext buildMapContext)
|
private void CreateReportFile(AssetBundleBuilder.BuildParametersContext buildParameters, BuildMapContext buildMapContext)
|
||||||
{
|
{
|
||||||
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory);
|
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory, buildParameters.Parameters.BuildVersion);
|
||||||
BuildReport buildReport = new BuildReport();
|
BuildReport buildReport = new BuildReport();
|
||||||
buildParameters.StopWatch();
|
buildParameters.StopWatch();
|
||||||
|
|
||||||
|
@ -79,7 +79,6 @@ namespace YooAsset.Editor
|
||||||
reportBundleInfo.Hash = patchBundle.Hash;
|
reportBundleInfo.Hash = patchBundle.Hash;
|
||||||
reportBundleInfo.CRC = patchBundle.CRC;
|
reportBundleInfo.CRC = patchBundle.CRC;
|
||||||
reportBundleInfo.SizeBytes = patchBundle.SizeBytes;
|
reportBundleInfo.SizeBytes = patchBundle.SizeBytes;
|
||||||
reportBundleInfo.Version = patchBundle.Version;
|
|
||||||
reportBundleInfo.Tags = patchBundle.Tags;
|
reportBundleInfo.Tags = patchBundle.Tags;
|
||||||
reportBundleInfo.Flags = patchBundle.Flags;
|
reportBundleInfo.Flags = patchBundle.Flags;
|
||||||
buildReport.BundleInfos.Add(reportBundleInfo);
|
buildReport.BundleInfos.Add(reportBundleInfo);
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace YooAsset.Editor
|
||||||
throw new Exception($"补丁包已经存在:{packageDirectory}");
|
throw new Exception($"补丁包已经存在:{packageDirectory}");
|
||||||
|
|
||||||
// 检测内置资源分类标签是否一致
|
// 检测内置资源分类标签是否一致
|
||||||
PatchManifest oldPatchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory);
|
var oldPatchManifest = AssetBundleBuilderHelper.GetOldPatchManifest(buildParameters.PipelineOutputDirectory);
|
||||||
if (buildParameters.Parameters.BuildinTags != oldPatchManifest.BuildinTags)
|
if (buildParameters.Parameters.BuildinTags != oldPatchManifest.BuildinTags)
|
||||||
throw new Exception($"增量更新时内置资源标签必须一致:{buildParameters.Parameters.BuildinTags} != {oldPatchManifest.BuildinTags}");
|
throw new Exception($"增量更新时内置资源标签必须一致:{buildParameters.Parameters.BuildinTags} != {oldPatchManifest.BuildinTags}");
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,16 +178,6 @@ namespace YooAsset.Editor
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
var label = new Label();
|
|
||||||
label.name = "Label2";
|
|
||||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
|
||||||
label.style.marginLeft = 3f;
|
|
||||||
//label.style.flexGrow = 1f;
|
|
||||||
label.style.width = 100;
|
|
||||||
element.Add(label);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
var label = new Label();
|
var label = new Label();
|
||||||
label.name = "Label3";
|
label.name = "Label3";
|
||||||
|
@ -219,10 +209,6 @@ namespace YooAsset.Editor
|
||||||
var label1 = element.Q<Label>("Label1");
|
var label1 = element.Q<Label>("Label1");
|
||||||
label1.text = bundleInfo.BundleName;
|
label1.text = bundleInfo.BundleName;
|
||||||
|
|
||||||
// Version
|
|
||||||
var label2 = element.Q<Label>("Label2");
|
|
||||||
label2.text = bundleInfo.Version.ToString();
|
|
||||||
|
|
||||||
// Ref Count
|
// Ref Count
|
||||||
var label3 = element.Q<Label>("Label3");
|
var label3 = element.Q<Label>("Label3");
|
||||||
label3.text = bundleInfo.RefCount.ToString();
|
label3.text = bundleInfo.RefCount.ToString();
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
|
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
|
||||||
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||||
<uie:ToolbarButton text="Depend Bundles" display-tooltip-when-elided="true" name="BottomBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
<uie:ToolbarButton text="Depend Bundles" display-tooltip-when-elided="true" name="BottomBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||||
<uie:ToolbarButton text="Version" display-tooltip-when-elided="true" name="BottomBar2" style="width: 100px; -unity-text-align: middle-left;" />
|
|
||||||
<uie:ToolbarButton text="Ref Count" display-tooltip-when-elided="true" name="BottomBar3" style="width: 100px; -unity-text-align: middle-left;" />
|
<uie:ToolbarButton text="Ref Count" display-tooltip-when-elided="true" name="BottomBar3" style="width: 100px; -unity-text-align: middle-left;" />
|
||||||
<uie:ToolbarButton text="Status" display-tooltip-when-elided="true" name="BottomBar4" style="width: 120px; -unity-text-align: middle-left;" />
|
<uie:ToolbarButton text="Status" display-tooltip-when-elided="true" name="BottomBar4" style="width: 120px; -unity-text-align: middle-left;" />
|
||||||
</uie:Toolbar>
|
</uie:Toolbar>
|
||||||
|
|
|
@ -112,16 +112,6 @@ namespace YooAsset.Editor
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
var label = new Label();
|
|
||||||
label.name = "Label2";
|
|
||||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
|
||||||
label.style.marginLeft = 3f;
|
|
||||||
//label.style.flexGrow = 1f;
|
|
||||||
label.style.width = 100;
|
|
||||||
element.Add(label);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
var label = new Label();
|
var label = new Label();
|
||||||
label.name = "Label3";
|
label.name = "Label3";
|
||||||
|
@ -153,10 +143,6 @@ namespace YooAsset.Editor
|
||||||
var label1 = element.Q<Label>("Label1");
|
var label1 = element.Q<Label>("Label1");
|
||||||
label1.text = bundleInfo.BundleName;
|
label1.text = bundleInfo.BundleName;
|
||||||
|
|
||||||
// Version
|
|
||||||
var label2 = element.Q<Label>("Label2");
|
|
||||||
label2.text = bundleInfo.Version.ToString();
|
|
||||||
|
|
||||||
// Ref Count
|
// Ref Count
|
||||||
var label3 = element.Q<Label>("Label3");
|
var label3 = element.Q<Label>("Label3");
|
||||||
label3.text = bundleInfo.RefCount.ToString();
|
label3.text = bundleInfo.RefCount.ToString();
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||||
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||||
<uie:ToolbarButton text="Bundle Name" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
<uie:ToolbarButton text="Bundle Name" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||||
<uie:ToolbarButton text="Version" display-tooltip-when-elided="true" name="TopBar2" style="width: 100px; -unity-text-align: middle-left;" />
|
|
||||||
<uie:ToolbarButton text="Ref Count" display-tooltip-when-elided="true" name="TopBar3" style="width: 100px; -unity-text-align: middle-left;" />
|
<uie:ToolbarButton text="Ref Count" display-tooltip-when-elided="true" name="TopBar3" style="width: 100px; -unity-text-align: middle-left;" />
|
||||||
<uie:ToolbarButton text="Status" display-tooltip-when-elided="true" name="TopBar4" style="width: 120px; -unity-text-align: middle-left;" />
|
<uie:ToolbarButton text="Status" display-tooltip-when-elided="true" name="TopBar4" style="width: 120px; -unity-text-align: middle-left;" />
|
||||||
</uie:Toolbar>
|
</uie:Toolbar>
|
||||||
|
|
|
@ -149,16 +149,6 @@ namespace YooAsset.Editor
|
||||||
element.Add(label);
|
element.Add(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
var label = new Label();
|
|
||||||
label.name = "Label4";
|
|
||||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
|
||||||
label.style.marginLeft = 3f;
|
|
||||||
//label.style.flexGrow = 1f;
|
|
||||||
label.style.width = 60;
|
|
||||||
element.Add(label);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
var label = new Label();
|
var label = new Label();
|
||||||
label.name = "Label5";
|
label.name = "Label5";
|
||||||
|
@ -188,10 +178,6 @@ namespace YooAsset.Editor
|
||||||
var label3 = element.Q<Label>("Label3");
|
var label3 = element.Q<Label>("Label3");
|
||||||
label3.text = bundleInfo.Hash;
|
label3.text = bundleInfo.Hash;
|
||||||
|
|
||||||
// Version
|
|
||||||
var label4 = element.Q<Label>("Label4");
|
|
||||||
label4.text = bundleInfo.Version.ToString();
|
|
||||||
|
|
||||||
// Tags
|
// Tags
|
||||||
var label5 = element.Q<Label>("Label5");
|
var label5 = element.Q<Label>("Label5");
|
||||||
label5.text = GetTagsString(bundleInfo.Tags);
|
label5.text = GetTagsString(bundleInfo.Tags);
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
<uie:ToolbarButton text="Bundle Name" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
<uie:ToolbarButton text="Bundle Name" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||||
<uie:ToolbarButton text="Size" display-tooltip-when-elided="true" name="TopBar2" style="width: 100px; -unity-text-align: middle-left; flex-grow: 0;" />
|
<uie:ToolbarButton text="Size" display-tooltip-when-elided="true" name="TopBar2" style="width: 100px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||||
<uie:ToolbarButton text="Hash" display-tooltip-when-elided="true" name="TopBar3" style="width: 250px; -unity-text-align: middle-left;" />
|
<uie:ToolbarButton text="Hash" display-tooltip-when-elided="true" name="TopBar3" style="width: 250px; -unity-text-align: middle-left;" />
|
||||||
<uie:ToolbarButton text="Version" display-tooltip-when-elided="true" name="TopBar4" style="width: 60px; -unity-text-align: middle-left;" />
|
|
||||||
<uie:ToolbarButton text="Tags" display-tooltip-when-elided="true" name="TopBar5" style="width: 80px; -unity-text-align: middle-left; flex-grow: 1;" />
|
<uie:ToolbarButton text="Tags" display-tooltip-when-elided="true" name="TopBar5" style="width: 80px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||||
</uie:Toolbar>
|
</uie:Toolbar>
|
||||||
<ui:ListView focusable="true" name="TopListView" item-height="18" style="flex-grow: 1;" />
|
<ui:ListView focusable="true" name="TopListView" item-height="18" style="flex-grow: 1;" />
|
||||||
|
|
|
@ -72,7 +72,6 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
var bundleInfo = new DebugBundleInfo();
|
var bundleInfo = new DebugBundleInfo();
|
||||||
bundleInfo.BundleName = loader.BundleFileInfo.BundleName;
|
bundleInfo.BundleName = loader.BundleFileInfo.BundleName;
|
||||||
bundleInfo.Version = loader.BundleFileInfo.Version;
|
|
||||||
bundleInfo.RefCount = loader.RefCount;
|
bundleInfo.RefCount = loader.RefCount;
|
||||||
bundleInfo.Status = loader.Status;
|
bundleInfo.Status = loader.Status;
|
||||||
output.Add(bundleInfo);
|
output.Add(bundleInfo);
|
||||||
|
|
|
@ -40,7 +40,6 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
var bundleInfo = new DebugBundleInfo();
|
var bundleInfo = new DebugBundleInfo();
|
||||||
bundleInfo.BundleName = OwnerBundle.BundleFileInfo.BundleName;
|
bundleInfo.BundleName = OwnerBundle.BundleFileInfo.BundleName;
|
||||||
bundleInfo.Version = OwnerBundle.BundleFileInfo.Version;
|
|
||||||
bundleInfo.RefCount = OwnerBundle.RefCount;
|
bundleInfo.RefCount = OwnerBundle.RefCount;
|
||||||
bundleInfo.Status = OwnerBundle.Status;
|
bundleInfo.Status = OwnerBundle.Status;
|
||||||
output.Add(bundleInfo);
|
output.Add(bundleInfo);
|
||||||
|
|
|
@ -8,11 +8,6 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string BundleName { set; get; }
|
public string BundleName { set; get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 资源版本
|
|
||||||
/// </summary>
|
|
||||||
public int Version { set; get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 引用计数
|
/// 引用计数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -67,20 +67,6 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 资源版本
|
|
||||||
/// </summary>
|
|
||||||
public int Version
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_patchBundle == null)
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return _patchBundle.Version;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否为加密文件
|
/// 是否为加密文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -34,15 +34,13 @@ namespace YooAsset
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
LoadAppManifest,
|
Update,
|
||||||
CheckAppManifest,
|
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private OfflinePlayModeImpl _impl;
|
private readonly OfflinePlayModeImpl _impl;
|
||||||
|
private readonly AppManifestLoader _appManifestLoader = new AppManifestLoader();
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
private UnityWebDataRequester _downloader;
|
|
||||||
private string _downloadURL;
|
|
||||||
|
|
||||||
internal OfflinePlayModeInitializationOperation(OfflinePlayModeImpl impl)
|
internal OfflinePlayModeInitializationOperation(OfflinePlayModeImpl impl)
|
||||||
{
|
{
|
||||||
|
@ -50,41 +48,32 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
internal override void Start()
|
internal override void Start()
|
||||||
{
|
{
|
||||||
_steps = ESteps.LoadAppManifest;
|
_steps = ESteps.Update;
|
||||||
}
|
}
|
||||||
internal override void Update()
|
internal override void Update()
|
||||||
{
|
{
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_steps == ESteps.LoadAppManifest)
|
if (_steps == ESteps.Update)
|
||||||
{
|
{
|
||||||
string filePath = PathHelper.MakeStreamingLoadPath(YooAssetSettingsData.Setting.PatchManifestFileName);
|
_appManifestLoader.Update();
|
||||||
_downloadURL = PathHelper.ConvertToWWWPath(filePath);
|
if (_appManifestLoader.IsDone() == false)
|
||||||
_downloader = new UnityWebDataRequester();
|
|
||||||
_downloader.SendRequest(_downloadURL);
|
|
||||||
_steps = ESteps.CheckAppManifest;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_steps == ESteps.CheckAppManifest)
|
|
||||||
{
|
|
||||||
if (_downloader.IsDone() == false)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_downloader.HasError())
|
if (_appManifestLoader.Result == null)
|
||||||
{
|
{
|
||||||
Error = _downloader.GetError();
|
|
||||||
_downloader.Dispose();
|
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
throw new System.Exception($"Fatal error : Failed load application patch manifest file : {_downloadURL}");
|
Error = _appManifestLoader.Error;
|
||||||
|
throw new System.Exception($"FATAL : {_appManifestLoader.Error}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
_impl.AppPatchManifest = _appManifestLoader.Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解析APP里的补丁清单
|
|
||||||
_impl.AppPatchManifest = PatchManifest.Deserialize(_downloader.GetText());
|
|
||||||
_downloader.Dispose();
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Succeed;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,16 +87,13 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
InitCache,
|
InitCache,
|
||||||
LoadAppManifest,
|
Update,
|
||||||
CheckAppManifest,
|
|
||||||
LoadSandboxManifest,
|
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private HostPlayModeImpl _impl;
|
private readonly HostPlayModeImpl _impl;
|
||||||
|
private readonly AppManifestLoader _appManifestLoader = new AppManifestLoader();
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
private UnityWebDataRequester _downloader;
|
|
||||||
private string _downloadURL;
|
|
||||||
|
|
||||||
internal HostPlayModeInitializationOperation(HostPlayModeImpl impl)
|
internal HostPlayModeInitializationOperation(HostPlayModeImpl impl)
|
||||||
{
|
{
|
||||||
|
@ -137,60 +123,137 @@ namespace YooAsset
|
||||||
SandboxHelper.DeleteSandboxCacheFolder();
|
SandboxHelper.DeleteSandboxCacheFolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除清单文件
|
|
||||||
SandboxHelper.DeleteSandboxPatchManifestFile();
|
|
||||||
// 更新缓存文件
|
// 更新缓存文件
|
||||||
PatchCache.UpdateCache();
|
PatchCache.UpdateCache();
|
||||||
}
|
}
|
||||||
_steps = ESteps.LoadAppManifest;
|
_steps = ESteps.Update;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.Update)
|
||||||
|
{
|
||||||
|
_appManifestLoader.Update();
|
||||||
|
if (_appManifestLoader.IsDone() == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_appManifestLoader.Result == null)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _appManifestLoader.Error;
|
||||||
|
throw new System.Exception($"FATAL : {_appManifestLoader.Error}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
_impl.AppPatchManifest = _appManifestLoader.Result;
|
||||||
|
_impl.LocalPatchManifest = _appManifestLoader.Result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 内置补丁清单加载器
|
||||||
|
/// </summary>
|
||||||
|
internal class AppManifestLoader
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
LoadStaticVersion,
|
||||||
|
CheckStaticVersion,
|
||||||
|
LoadAppManifest,
|
||||||
|
CheckAppManifest,
|
||||||
|
Succeed,
|
||||||
|
Failed,
|
||||||
|
}
|
||||||
|
|
||||||
|
private ESteps _steps = ESteps.LoadStaticVersion;
|
||||||
|
private UnityWebDataRequester _downloader1;
|
||||||
|
private UnityWebDataRequester _downloader2;
|
||||||
|
private int _staticVersion = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 错误日志
|
||||||
|
/// </summary>
|
||||||
|
public string Error { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 补丁清单
|
||||||
|
/// </summary>
|
||||||
|
public PatchManifest Result { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否已经完成
|
||||||
|
/// </summary>
|
||||||
|
public bool IsDone()
|
||||||
|
{
|
||||||
|
if (_steps == ESteps.Succeed || _steps == ESteps.Failed)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update()
|
||||||
|
{
|
||||||
|
if (IsDone())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.LoadStaticVersion)
|
||||||
|
{
|
||||||
|
YooLogger.Log($"Load application static version.");
|
||||||
|
string filePath = PathHelper.MakeStreamingLoadPath(YooAssetSettings.VersionFileName);
|
||||||
|
string url = PathHelper.ConvertToWWWPath(filePath);
|
||||||
|
_downloader1 = new UnityWebDataRequester();
|
||||||
|
_downloader1.SendRequest(url);
|
||||||
|
_steps = ESteps.CheckStaticVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.CheckStaticVersion)
|
||||||
|
{
|
||||||
|
if (_downloader1.IsDone() == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_downloader1.HasError())
|
||||||
|
{
|
||||||
|
Error = _downloader1.GetError();
|
||||||
|
_steps = ESteps.Failed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_staticVersion = int.Parse(_downloader1.GetText());
|
||||||
|
_steps = ESteps.LoadAppManifest;
|
||||||
|
}
|
||||||
|
_downloader1.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.LoadAppManifest)
|
if (_steps == ESteps.LoadAppManifest)
|
||||||
{
|
{
|
||||||
// 加载APP内的补丁清单
|
|
||||||
YooLogger.Log($"Load application patch manifest.");
|
YooLogger.Log($"Load application patch manifest.");
|
||||||
string filePath = PathHelper.MakeStreamingLoadPath(YooAssetSettingsData.Setting.PatchManifestFileName);
|
string filePath = PathHelper.MakeStreamingLoadPath(YooAssetSettingsData.GetPatchManifestFileName(_staticVersion));
|
||||||
_downloadURL = PathHelper.ConvertToWWWPath(filePath);
|
string url = PathHelper.ConvertToWWWPath(filePath);
|
||||||
_downloader = new UnityWebDataRequester();
|
_downloader2 = new UnityWebDataRequester();
|
||||||
_downloader.SendRequest(_downloadURL);
|
_downloader2.SendRequest(url);
|
||||||
_steps = ESteps.CheckAppManifest;
|
_steps = ESteps.CheckAppManifest;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.CheckAppManifest)
|
if (_steps == ESteps.CheckAppManifest)
|
||||||
{
|
{
|
||||||
if (_downloader.IsDone() == false)
|
if (_downloader2.IsDone() == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_downloader.HasError())
|
if (_downloader2.HasError())
|
||||||
{
|
{
|
||||||
Error = _downloader.GetError();
|
Error = _downloader2.GetError();
|
||||||
_downloader.Dispose();
|
_steps = ESteps.Failed;
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
throw new System.Exception($"Fatal error : Failed load application patch manifest file : {_downloadURL}");
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
// 解析补丁清单
|
|
||||||
string jsonData = _downloader.GetText();
|
|
||||||
_impl.AppPatchManifest = PatchManifest.Deserialize(jsonData);
|
|
||||||
_impl.LocalPatchManifest = _impl.AppPatchManifest;
|
|
||||||
_downloader.Dispose();
|
|
||||||
_steps = ESteps.LoadSandboxManifest;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_steps == ESteps.LoadSandboxManifest)
|
|
||||||
{
|
|
||||||
// 加载沙盒内的补丁清单
|
|
||||||
if (SandboxHelper.CheckSandboxPatchManifestFileExist())
|
|
||||||
{
|
{
|
||||||
YooLogger.Log($"Load sandbox patch manifest.");
|
// 解析APP里的补丁清单
|
||||||
string filePath = PathHelper.MakePersistentLoadPath(YooAssetSettingsData.Setting.PatchManifestFileName);
|
Result = PatchManifest.Deserialize(_downloader2.GetText());
|
||||||
string jsonData = File.ReadAllText(filePath);
|
_steps = ESteps.Succeed;
|
||||||
_impl.LocalPatchManifest = PatchManifest.Deserialize(jsonData);
|
|
||||||
}
|
}
|
||||||
|
_downloader2.Dispose();
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Succeed;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,6 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int RequestCount = 0;
|
private static int RequestCount = 0;
|
||||||
|
|
||||||
private readonly HostPlayModeImpl _impl;
|
private readonly HostPlayModeImpl _impl;
|
||||||
private readonly int _updateResourceVersion;
|
private readonly int _updateResourceVersion;
|
||||||
private readonly int _timeout;
|
private readonly int _timeout;
|
||||||
|
@ -78,15 +77,6 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
RequestCount++;
|
RequestCount++;
|
||||||
_steps = ESteps.LoadWebManifestHash;
|
_steps = ESteps.LoadWebManifestHash;
|
||||||
|
|
||||||
if (_impl.IgnoreResourceVersion && _updateResourceVersion > 0)
|
|
||||||
{
|
|
||||||
YooLogger.Warning($"Update resource version {_updateResourceVersion} is invalid when ignore resource version.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
YooLogger.Log($"Update patch manifest : update resource version is {_updateResourceVersion}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
internal override void Update()
|
internal override void Update()
|
||||||
{
|
{
|
||||||
|
@ -95,7 +85,7 @@ namespace YooAsset
|
||||||
|
|
||||||
if (_steps == ESteps.LoadWebManifestHash)
|
if (_steps == ESteps.LoadWebManifestHash)
|
||||||
{
|
{
|
||||||
string webURL = GetPatchManifestRequestURL(_updateResourceVersion, YooAssetSettingsData.Setting.PatchManifestHashFileName);
|
string webURL = GetPatchManifestRequestURL(YooAssetSettingsData.GetPatchManifestHashFileName(_updateResourceVersion));
|
||||||
YooLogger.Log($"Beginning to request patch manifest hash : {webURL}");
|
YooLogger.Log($"Beginning to request patch manifest hash : {webURL}");
|
||||||
_downloaderHash = new UnityWebDataRequester();
|
_downloaderHash = new UnityWebDataRequester();
|
||||||
_downloaderHash.SendRequest(webURL, _timeout);
|
_downloaderHash.SendRequest(webURL, _timeout);
|
||||||
|
@ -107,37 +97,36 @@ namespace YooAsset
|
||||||
if (_downloaderHash.IsDone() == false)
|
if (_downloaderHash.IsDone() == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Check fatal
|
// Check error
|
||||||
if (_downloaderHash.HasError())
|
if (_downloaderHash.HasError())
|
||||||
{
|
{
|
||||||
Error = _downloaderHash.GetError();
|
|
||||||
_downloaderHash.Dispose();
|
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
return;
|
Error = _downloaderHash.GetError();
|
||||||
}
|
|
||||||
|
|
||||||
// 获取补丁清单文件的哈希值
|
|
||||||
string webManifestHash = _downloaderHash.GetText();
|
|
||||||
_downloaderHash.Dispose();
|
|
||||||
|
|
||||||
// 如果补丁清单文件的哈希值相同
|
|
||||||
string currentFileHash = SandboxHelper.GetSandboxPatchManifestFileHash();
|
|
||||||
if (currentFileHash == webManifestHash)
|
|
||||||
{
|
|
||||||
YooLogger.Log($"Patch manifest file hash is not change : {webManifestHash}");
|
|
||||||
_steps = ESteps.InitPrepareCache;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
YooLogger.Log($"Patch manifest hash is change : {webManifestHash} -> {currentFileHash}");
|
string webManifestHash = _downloaderHash.GetText();
|
||||||
_steps = ESteps.LoadWebManifest;
|
string cachedManifestHash = GetSandboxPatchManifestFileHash(_updateResourceVersion);
|
||||||
|
|
||||||
|
// 如果补丁清单文件的哈希值相同
|
||||||
|
if (cachedManifestHash == webManifestHash)
|
||||||
|
{
|
||||||
|
YooLogger.Log($"Patch manifest file hash is not change : {webManifestHash}");
|
||||||
|
_steps = ESteps.InitPrepareCache;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
YooLogger.Log($"Patch manifest hash is change : {webManifestHash} -> {cachedManifestHash}");
|
||||||
|
_steps = ESteps.LoadWebManifest;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
_downloaderHash.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.LoadWebManifest)
|
if (_steps == ESteps.LoadWebManifest)
|
||||||
{
|
{
|
||||||
string webURL = GetPatchManifestRequestURL(_updateResourceVersion, YooAssetSettingsData.Setting.PatchManifestFileName);
|
string webURL = GetPatchManifestRequestURL(YooAssetSettingsData.GetPatchManifestFileName(_updateResourceVersion));
|
||||||
YooLogger.Log($"Beginning to request patch manifest : {webURL}");
|
YooLogger.Log($"Beginning to request patch manifest : {webURL}");
|
||||||
_downloaderManifest = new UnityWebDataRequester();
|
_downloaderManifest = new UnityWebDataRequester();
|
||||||
_downloaderManifest.SendRequest(webURL, _timeout);
|
_downloaderManifest.SendRequest(webURL, _timeout);
|
||||||
|
@ -149,20 +138,28 @@ namespace YooAsset
|
||||||
if (_downloaderManifest.IsDone() == false)
|
if (_downloaderManifest.IsDone() == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Check fatal
|
// Check error
|
||||||
if (_downloaderManifest.HasError())
|
if (_downloaderManifest.HasError())
|
||||||
{
|
{
|
||||||
Error = _downloaderManifest.GetError();
|
|
||||||
_downloaderManifest.Dispose();
|
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
return;
|
Error = _downloaderManifest.GetError();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 解析补丁清单
|
||||||
|
if (ParseAndSaveRemotePatchManifest(_updateResourceVersion, _downloaderManifest.GetText()))
|
||||||
|
{
|
||||||
|
_steps = ESteps.InitPrepareCache;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"URL : {_downloaderManifest.URL} Error : remote patch manifest content is invalid";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解析补丁清单
|
|
||||||
ParseAndSaveRemotePatchManifest(_downloaderManifest.GetText());
|
|
||||||
_downloaderManifest.Dispose();
|
_downloaderManifest.Dispose();
|
||||||
_steps = ESteps.InitPrepareCache;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.InitPrepareCache)
|
if (_steps == ESteps.InitPrepareCache)
|
||||||
|
@ -184,30 +181,47 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetPatchManifestRequestURL(int updateResourceVersion, string fileName)
|
private string GetPatchManifestRequestURL(string fileName)
|
||||||
{
|
{
|
||||||
string url;
|
|
||||||
|
|
||||||
// 轮流返回请求地址
|
// 轮流返回请求地址
|
||||||
if (RequestCount % 2 == 0)
|
if (RequestCount % 2 == 0)
|
||||||
url = _impl.GetPatchDownloadFallbackURL(updateResourceVersion, fileName);
|
return _impl.GetPatchDownloadFallbackURL(fileName);
|
||||||
else
|
else
|
||||||
url = _impl.GetPatchDownloadMainURL(updateResourceVersion, fileName);
|
return _impl.GetPatchDownloadMainURL(fileName);
|
||||||
|
|
||||||
// 注意:在URL末尾添加时间戳
|
|
||||||
if (_impl.IgnoreResourceVersion)
|
|
||||||
url = $"{url}?{System.DateTime.UtcNow.Ticks}";
|
|
||||||
|
|
||||||
return url;
|
|
||||||
}
|
}
|
||||||
private void ParseAndSaveRemotePatchManifest(string content)
|
|
||||||
{
|
|
||||||
_impl.LocalPatchManifest = PatchManifest.Deserialize(content);
|
|
||||||
|
|
||||||
// 注意:这里会覆盖掉沙盒内的补丁清单文件
|
/// <summary>
|
||||||
YooLogger.Log("Save remote patch manifest file.");
|
/// 解析并保存远端请求的补丁清单
|
||||||
string savePath = PathHelper.MakePersistentLoadPath(YooAssetSettingsData.Setting.PatchManifestFileName);
|
/// </summary>
|
||||||
PatchManifest.Serialize(savePath, _impl.LocalPatchManifest);
|
private bool ParseAndSaveRemotePatchManifest(int updateResourceVersion, string content)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_impl.LocalPatchManifest = PatchManifest.Deserialize(content);
|
||||||
|
|
||||||
|
YooLogger.Log("Save remote patch manifest file.");
|
||||||
|
string savePath = PathHelper.MakePersistentLoadPath(YooAssetSettingsData.GetPatchManifestFileName(updateResourceVersion));
|
||||||
|
PatchManifest.Serialize(savePath, _impl.LocalPatchManifest);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
YooLogger.Warning(e.ToString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取沙盒内补丁清单文件的哈希值
|
||||||
|
/// 注意:如果沙盒内补丁清单文件不存在,返回空字符串
|
||||||
|
/// </summary>
|
||||||
|
private string GetSandboxPatchManifestFileHash(int updateResourceVersion)
|
||||||
|
{
|
||||||
|
string filePath = PathHelper.MakePersistentLoadPath(YooAssetSettingsData.GetPatchManifestFileName(updateResourceVersion));
|
||||||
|
if (File.Exists(filePath))
|
||||||
|
return HashUtility.FileMD5(filePath);
|
||||||
|
else
|
||||||
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 多线程相关
|
#region 多线程相关
|
||||||
|
|
|
@ -0,0 +1,134 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 更新静态版本操作
|
||||||
|
/// </summary>
|
||||||
|
public abstract class UpdateStaticVersionOperation : AsyncOperationBase
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 资源版本号
|
||||||
|
/// </summary>
|
||||||
|
public int ResourceVersion { protected set; get; } = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑器下模拟运行的更新静态版本操作
|
||||||
|
/// </summary>
|
||||||
|
internal class EditorModeUpdateStaticVersionOperation : UpdateStaticVersionOperation
|
||||||
|
{
|
||||||
|
internal override void Start()
|
||||||
|
{
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
internal override void Update()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 离线模式的更新静态版本操作
|
||||||
|
/// </summary>
|
||||||
|
internal class OfflinePlayModeUpdateStaticVersionOperation : UpdateStaticVersionOperation
|
||||||
|
{
|
||||||
|
internal override void Start()
|
||||||
|
{
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
internal override void Update()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 网络模式的更新静态版本操作
|
||||||
|
/// </summary>
|
||||||
|
internal class HostPlayModeUpdateStaticVersionOperation : UpdateStaticVersionOperation
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
LoadStaticVersion,
|
||||||
|
CheckStaticVersion,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int RequestCount = 0;
|
||||||
|
private readonly HostPlayModeImpl _impl;
|
||||||
|
private readonly int _timeout;
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
private UnityWebDataRequester _downloader;
|
||||||
|
|
||||||
|
internal HostPlayModeUpdateStaticVersionOperation(HostPlayModeImpl impl, int timeout)
|
||||||
|
{
|
||||||
|
_impl = impl;
|
||||||
|
_timeout = timeout;
|
||||||
|
}
|
||||||
|
internal override void Start()
|
||||||
|
{
|
||||||
|
RequestCount++;
|
||||||
|
_steps = ESteps.LoadStaticVersion;
|
||||||
|
}
|
||||||
|
internal override void Update()
|
||||||
|
{
|
||||||
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.LoadStaticVersion)
|
||||||
|
{
|
||||||
|
string webURL = GetStaticVersionRequestURL(YooAssetSettings.VersionFileName);
|
||||||
|
YooLogger.Log($"Beginning to request static version : {webURL}");
|
||||||
|
_downloader = new UnityWebDataRequester();
|
||||||
|
_downloader.SendRequest(webURL, _timeout);
|
||||||
|
_steps = ESteps.CheckStaticVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.CheckStaticVersion)
|
||||||
|
{
|
||||||
|
if (_downloader.IsDone() == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_downloader.HasError())
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _downloader.GetError();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (int.TryParse(_downloader.GetText(), out int value))
|
||||||
|
{
|
||||||
|
ResourceVersion = value;
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"URL : {_downloader.URL} Error : static version content is invalid.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_downloader.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetStaticVersionRequestURL(string fileName)
|
||||||
|
{
|
||||||
|
string url;
|
||||||
|
|
||||||
|
// 轮流返回请求地址
|
||||||
|
if (RequestCount % 2 == 0)
|
||||||
|
url = _impl.GetPatchDownloadFallbackURL(fileName);
|
||||||
|
else
|
||||||
|
url = _impl.GetPatchDownloadMainURL(fileName);
|
||||||
|
|
||||||
|
// 注意:在URL末尾添加时间戳
|
||||||
|
return $"{url}?{System.DateTime.UtcNow.Ticks}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 60bb21def73049e4f83a108d0e741301
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -26,11 +26,6 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long SizeBytes;
|
public long SizeBytes;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 文件版本
|
|
||||||
/// </summary>
|
|
||||||
public int Version;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tags
|
/// Tags
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -59,13 +54,12 @@ namespace YooAsset
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public PatchBundle(string bundleName, string hash, string crc, long sizeBytes, int version, string[] tags)
|
public PatchBundle(string bundleName, string hash, string crc, long sizeBytes, string[] tags)
|
||||||
{
|
{
|
||||||
BundleName = bundleName;
|
BundleName = bundleName;
|
||||||
Hash = hash;
|
Hash = hash;
|
||||||
CRC = crc;
|
CRC = crc;
|
||||||
SizeBytes = sizeBytes;
|
SizeBytes = sizeBytes;
|
||||||
Version = version;
|
|
||||||
Tags = tags;
|
Tags = tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,15 +20,16 @@ namespace YooAsset
|
||||||
public static PatchCache LoadCache()
|
public static PatchCache LoadCache()
|
||||||
{
|
{
|
||||||
if (SandboxHelper.CheckSandboxCacheFileExist())
|
if (SandboxHelper.CheckSandboxCacheFileExist())
|
||||||
{
|
{
|
||||||
YooLogger.Log("Load patch cache from disk.");
|
|
||||||
string filePath = SandboxHelper.GetSandboxCacheFilePath();
|
string filePath = SandboxHelper.GetSandboxCacheFilePath();
|
||||||
string jsonData = FileUtility.ReadFile(filePath);
|
string jsonData = FileUtility.ReadFile(filePath);
|
||||||
return JsonUtility.FromJson<PatchCache>(jsonData);
|
var patchCache = JsonUtility.FromJson<PatchCache>(jsonData);
|
||||||
|
YooLogger.Log($"Load cache file : {patchCache.CacheAppVersion}");
|
||||||
|
return patchCache;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
YooLogger.Log($"Create patch cache to disk : {Application.version}");
|
YooLogger.Log($"Create cache file : {Application.version}");
|
||||||
PatchCache cache = new PatchCache();
|
PatchCache cache = new PatchCache();
|
||||||
cache.CacheAppVersion = Application.version;
|
cache.CacheAppVersion = Application.version;
|
||||||
string filePath = SandboxHelper.GetSandboxCacheFilePath();
|
string filePath = SandboxHelper.GetSandboxCacheFilePath();
|
||||||
|
|
|
@ -12,18 +12,15 @@ namespace YooAsset
|
||||||
|
|
||||||
// 参数相关
|
// 参数相关
|
||||||
internal bool ClearCacheWhenDirty { private set; get; }
|
internal bool ClearCacheWhenDirty { private set; get; }
|
||||||
internal bool IgnoreResourceVersion { private set; get; }
|
|
||||||
private string _defaultHostServer;
|
private string _defaultHostServer;
|
||||||
private string _fallbackHostServer;
|
private string _fallbackHostServer;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步初始化
|
/// 异步初始化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public InitializationOperation InitializeAsync(bool clearCacheWhenDirty, bool ignoreResourceVersion,
|
public InitializationOperation InitializeAsync(bool clearCacheWhenDirty, string defaultHostServer, string fallbackHostServer)
|
||||||
string defaultHostServer, string fallbackHostServer)
|
|
||||||
{
|
{
|
||||||
ClearCacheWhenDirty = clearCacheWhenDirty;
|
ClearCacheWhenDirty = clearCacheWhenDirty;
|
||||||
IgnoreResourceVersion = ignoreResourceVersion;
|
|
||||||
_defaultHostServer = defaultHostServer;
|
_defaultHostServer = defaultHostServer;
|
||||||
_fallbackHostServer = fallbackHostServer;
|
_fallbackHostServer = fallbackHostServer;
|
||||||
|
|
||||||
|
@ -32,6 +29,16 @@ namespace YooAsset
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异步更新资源版本号
|
||||||
|
/// </summary>
|
||||||
|
public UpdateStaticVersionOperation UpdateStaticVersionAsync(int timeout)
|
||||||
|
{
|
||||||
|
var operation = new HostPlayModeUpdateStaticVersionOperation(this, timeout);
|
||||||
|
OperationSystem.ProcessOperaiton(operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步更新补丁清单
|
/// 异步更新补丁清单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -166,19 +173,13 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
// WEB相关
|
// WEB相关
|
||||||
public string GetPatchDownloadMainURL(int resourceVersion, string fileName)
|
public string GetPatchDownloadMainURL(string fileName)
|
||||||
{
|
{
|
||||||
if (IgnoreResourceVersion)
|
return $"{_defaultHostServer}/{fileName}";
|
||||||
return $"{_defaultHostServer}/{fileName}";
|
|
||||||
else
|
|
||||||
return $"{_defaultHostServer}/{resourceVersion}/{fileName}";
|
|
||||||
}
|
}
|
||||||
public string GetPatchDownloadFallbackURL(int resourceVersion, string fileName)
|
public string GetPatchDownloadFallbackURL(string fileName)
|
||||||
{
|
{
|
||||||
if (IgnoreResourceVersion)
|
return $"{_fallbackHostServer}/{fileName}";
|
||||||
return $"{_fallbackHostServer}/{fileName}";
|
|
||||||
else
|
|
||||||
return $"{_fallbackHostServer}/{resourceVersion}/{fileName}";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 下载相关
|
// 下载相关
|
||||||
|
@ -196,8 +197,8 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
// 注意:资源版本号只用于确定下载路径
|
// 注意:资源版本号只用于确定下载路径
|
||||||
string sandboxPath = SandboxHelper.MakeSandboxCacheFilePath(patchBundle.Hash);
|
string sandboxPath = SandboxHelper.MakeSandboxCacheFilePath(patchBundle.Hash);
|
||||||
string remoteMainURL = GetPatchDownloadMainURL(patchBundle.Version, patchBundle.Hash);
|
string remoteMainURL = GetPatchDownloadMainURL(patchBundle.Hash);
|
||||||
string remoteFallbackURL = GetPatchDownloadFallbackURL(patchBundle.Version, patchBundle.Hash);
|
string remoteFallbackURL = GetPatchDownloadFallbackURL(patchBundle.Hash);
|
||||||
BundleInfo bundleInfo = new BundleInfo(patchBundle, sandboxPath, remoteMainURL, remoteFallbackURL);
|
BundleInfo bundleInfo = new BundleInfo(patchBundle, sandboxPath, remoteMainURL, remoteFallbackURL);
|
||||||
return bundleInfo;
|
return bundleInfo;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
/*
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
internal class WebPlayModeImpl : IBundleServices
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 03baa90d8f534834c9c31d469a507f66
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -18,12 +18,7 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建输出的补丁清单文件名称
|
/// 构建输出的补丁清单文件名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PatchManifestFileName = "PatchManifest.bytes";
|
public string PatchManifestFileName = "PatchManifest";
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 构建输出的补丁清单哈希文件名称
|
|
||||||
/// </summary>
|
|
||||||
public string PatchManifestHashFileName = "PatchManifestHash.bytes";
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建输出的Unity清单文件名称
|
/// 构建输出的Unity清单文件名称
|
||||||
|
@ -34,5 +29,10 @@ namespace YooAsset
|
||||||
/// 构建输出的报告文件
|
/// 构建输出的报告文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string ReportFileName = "BuildReport.json";
|
public const string ReportFileName = "BuildReport.json";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 静态版本文件
|
||||||
|
/// </summary>
|
||||||
|
public const string VersionFileName = "StaticVersion.bytes";
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -31,5 +31,21 @@ namespace YooAsset
|
||||||
YooLogger.Log("YooAsset use custom settings.");
|
YooLogger.Log("YooAsset use custom settings.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取补丁清单文件完整名称
|
||||||
|
/// </summary>
|
||||||
|
public static string GetPatchManifestFileName(int resourceVersion)
|
||||||
|
{
|
||||||
|
return $"{Setting.PatchManifestFileName}_{resourceVersion}.bytes";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取补丁清单哈希文件完整名称
|
||||||
|
/// </summary>
|
||||||
|
public static string GetPatchManifestHashFileName(int resourceVersion)
|
||||||
|
{
|
||||||
|
return $"{Setting.PatchManifestFileName}_{resourceVersion}.hash";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -143,16 +143,6 @@ namespace YooAsset
|
||||||
Directory.Delete(directoryPath, true);
|
Directory.Delete(directoryPath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 删除沙盒内补丁清单文件
|
|
||||||
/// </summary>
|
|
||||||
public static void DeleteSandboxPatchManifestFile()
|
|
||||||
{
|
|
||||||
string filePath = PathHelper.MakePersistentLoadPath(YooAssetSettingsData.Setting.PatchManifestFileName);
|
|
||||||
if (File.Exists(filePath))
|
|
||||||
File.Delete(filePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 删除沙盒内的缓存文件
|
/// 删除沙盒内的缓存文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -191,28 +181,6 @@ namespace YooAsset
|
||||||
return File.Exists(filePath);
|
return File.Exists(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 检测沙盒内补丁清单文件是否存在
|
|
||||||
/// </summary>
|
|
||||||
public static bool CheckSandboxPatchManifestFileExist()
|
|
||||||
{
|
|
||||||
string filePath = PathHelper.MakePersistentLoadPath(YooAssetSettingsData.Setting.PatchManifestFileName);
|
|
||||||
return File.Exists(filePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 获取沙盒内补丁清单文件的哈希值
|
|
||||||
/// 注意:如果沙盒内补丁清单文件不存在,返回空字符串
|
|
||||||
/// </summary>
|
|
||||||
public static string GetSandboxPatchManifestFileHash()
|
|
||||||
{
|
|
||||||
string filePath = PathHelper.MakePersistentLoadPath(YooAssetSettingsData.Setting.PatchManifestFileName);
|
|
||||||
if (File.Exists(filePath))
|
|
||||||
return HashUtility.FileMD5(filePath);
|
|
||||||
else
|
|
||||||
return string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取缓存文件的存储路径
|
/// 获取缓存文件的存储路径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -82,11 +82,6 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool ClearCacheWhenDirty;
|
public bool ClearCacheWhenDirty;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 忽略资源版本号
|
|
||||||
/// </summary>
|
|
||||||
public bool IgnoreResourceVersion;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 默认的资源服务器下载地址
|
/// 默认的资源服务器下载地址
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -207,7 +202,6 @@ namespace YooAsset
|
||||||
var hostPlayModeParameters = parameters as HostPlayModeParameters;
|
var hostPlayModeParameters = parameters as HostPlayModeParameters;
|
||||||
return _hostPlayModeImpl.InitializeAsync(
|
return _hostPlayModeImpl.InitializeAsync(
|
||||||
hostPlayModeParameters.ClearCacheWhenDirty,
|
hostPlayModeParameters.ClearCacheWhenDirty,
|
||||||
hostPlayModeParameters.IgnoreResourceVersion,
|
|
||||||
hostPlayModeParameters.DefaultHostServer,
|
hostPlayModeParameters.DefaultHostServer,
|
||||||
hostPlayModeParameters.FallbackHostServer);
|
hostPlayModeParameters.FallbackHostServer);
|
||||||
}
|
}
|
||||||
|
@ -217,6 +211,37 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 向网络端请求静态资源版本号
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static UpdateStaticVersionOperation UpdateStaticVersionAsync(int timeout = 60)
|
||||||
|
{
|
||||||
|
if (_playMode == EPlayMode.EditorPlayMode)
|
||||||
|
{
|
||||||
|
var operation = new EditorModeUpdateStaticVersionOperation();
|
||||||
|
OperationSystem.ProcessOperaiton(operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||||
|
{
|
||||||
|
var operation = new OfflinePlayModeUpdateStaticVersionOperation();
|
||||||
|
OperationSystem.ProcessOperaiton(operation);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
else if (_playMode == EPlayMode.HostPlayMode)
|
||||||
|
{
|
||||||
|
if (_hostPlayModeImpl == null)
|
||||||
|
throw new Exception("YooAsset is not initialized.");
|
||||||
|
return _hostPlayModeImpl.UpdateStaticVersionAsync(timeout);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 向网络端请求并更新补丁清单
|
/// 向网络端请求并更新补丁清单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in New Issue