parent
889000d8a8
commit
d67fc31c26
|
@ -190,6 +190,7 @@ namespace YooAsset
|
|||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
CheckAppFootPrint,
|
||||
TryLoadCacheManifest,
|
||||
QueryAppPackageVersion,
|
||||
CopyAppManifest,
|
||||
|
@ -222,13 +223,28 @@ namespace YooAsset
|
|||
}
|
||||
internal override void Start()
|
||||
{
|
||||
_steps = ESteps.TryLoadCacheManifest;
|
||||
_steps = ESteps.CheckAppFootPrint;
|
||||
}
|
||||
internal override void Update()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.CheckAppFootPrint)
|
||||
{
|
||||
var appFootPrint = new AppFootPrint();
|
||||
appFootPrint.Load();
|
||||
|
||||
// 如果水印发生变化,则说明覆盖安装后首次打开游戏
|
||||
if (appFootPrint.IsDirty())
|
||||
{
|
||||
PersistentHelper.DeleteManifestFolder();
|
||||
appFootPrint.Coverage();
|
||||
YooLogger.Log("Delete manifest files when application foot print dirty !");
|
||||
}
|
||||
_steps = ESteps.TryLoadCacheManifest;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.TryLoadCacheManifest)
|
||||
{
|
||||
if (PersistentHelper.CheckCacheManifestFileExists(_packageName))
|
||||
|
@ -341,6 +357,57 @@ namespace YooAsset
|
|||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 应用程序水印
|
||||
/// </summary>
|
||||
internal class AppFootPrint
|
||||
{
|
||||
private string _footPrint;
|
||||
|
||||
/// <summary>
|
||||
/// 读取应用程序水印
|
||||
/// </summary>
|
||||
public void Load()
|
||||
{
|
||||
string footPrintFilePath = PersistentHelper.GetAppFootPrintFilePath();
|
||||
if (File.Exists(footPrintFilePath))
|
||||
{
|
||||
_footPrint = FileUtility.ReadAllText(footPrintFilePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
Coverage();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测水印是否发生变化
|
||||
/// </summary>
|
||||
public bool IsDirty()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
return _footPrint != Application.version;
|
||||
#else
|
||||
return _footPrint != Application.buildGUID;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 覆盖掉水印
|
||||
/// </summary>
|
||||
public void Coverage()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
_footPrint = Application.version;
|
||||
#else
|
||||
_footPrint = Application.buildGUID;
|
||||
#endif
|
||||
string footPrintFilePath = PersistentHelper.GetAppFootPrintFilePath();
|
||||
FileUtility.CreateFile(footPrintFilePath, _footPrint);
|
||||
YooLogger.Log($"Save application foot print : {_footPrint}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 内置补丁清单版本查询器
|
||||
/// </summary>
|
||||
|
|
|
@ -84,6 +84,8 @@ namespace YooAsset
|
|||
internal static class PersistentHelper
|
||||
{
|
||||
private const string CacheFolderName = "CacheFiles";
|
||||
private const string ManifestFolderName = "ManifestFiles";
|
||||
private const string AppFootPrintFileName = "ApplicationFootPrint.bytes";
|
||||
|
||||
/// <summary>
|
||||
/// 删除沙盒总目录
|
||||
|
@ -105,6 +107,16 @@ namespace YooAsset
|
|||
Directory.Delete(root, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除沙盒内的清单文件夹
|
||||
/// </summary>
|
||||
public static void DeleteManifestFolder()
|
||||
{
|
||||
string root = PathHelper.MakePersistentLoadPath(ManifestFolderName);
|
||||
if (Directory.Exists(root))
|
||||
Directory.Delete(root, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取缓存文件夹路径
|
||||
/// </summary>
|
||||
|
@ -114,6 +126,14 @@ namespace YooAsset
|
|||
return $"{root}/{packageName}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取应用程序的水印文件路径
|
||||
/// </summary>
|
||||
public static string GetAppFootPrintFilePath()
|
||||
{
|
||||
return PathHelper.MakePersistentLoadPath(AppFootPrintFileName);
|
||||
}
|
||||
|
||||
#region 沙盒内清单相关
|
||||
/// <summary>
|
||||
/// 获取沙盒内清单文件的路径
|
||||
|
@ -121,7 +141,7 @@ namespace YooAsset
|
|||
public static string GetCacheManifestFilePath(string packageName)
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPatchManifestFileNameWithoutVersion(packageName);
|
||||
return PathHelper.MakePersistentLoadPath(fileName);
|
||||
return PathHelper.MakePersistentLoadPath($"{ManifestFolderName}/{fileName}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue