Update YooAsset

This commit is contained in:
hevinci
2022-03-09 21:53:01 +08:00
parent c3ecca7cfd
commit 1c7b90806c
77 changed files with 596 additions and 604 deletions

View File

@@ -2,7 +2,6 @@
using System.IO;
using System.Collections;
using System.Collections.Generic;
using YooAsset.Utility;
namespace YooAsset
{
@@ -62,7 +61,7 @@ namespace YooAsset
// 创建新的下载器
{
Logger.Log($"Beginning to download file : {bundleInfo.BundleName} URL : {bundleInfo.RemoteMainURL}");
YooLogger.Log($"Beginning to download file : {bundleInfo.BundleName} URL : {bundleInfo.RemoteMainURL}");
FileUtility.CreateFileDirectory(bundleInfo.LocalPath);
var newDownloader = new FileDownloader(bundleInfo);
newDownloader.SendRequest(failedTryAgain, timeout);
@@ -96,7 +95,7 @@ namespace YooAsset
{
string bundleName = _cachedHashList[hash];
_cachedHashList.Remove(hash);
Logger.Error($"Cache file is missing : {bundleName} Hash : {hash}");
YooLogger.Error($"Cache file is missing : {bundleName} Hash : {hash}");
return false;
}
}
@@ -113,7 +112,7 @@ namespace YooAsset
{
if (_cachedHashList.ContainsKey(hash) == false)
{
Logger.Log($"Cache verify file : {bundleName} Hash : {hash}");
YooLogger.Log($"Cache verify file : {bundleName} Hash : {hash}");
_cachedHashList.Add(hash, bundleName);
}
}

View File

@@ -159,7 +159,7 @@ namespace YooAsset
{
_failedTryAgain--;
_steps = ESteps.CreateDownload;
Logger.Warning($"Try again download : {_requestURL}");
YooLogger.Warning($"Try again download : {_requestURL}");
}
}
}
@@ -190,7 +190,7 @@ namespace YooAsset
float offset = Time.realtimeSinceStartup - _latestDownloadRealtime;
if (offset > _timeout)
{
Logger.Warning($"Web file request timeout : {_requestURL}");
YooLogger.Warning($"Web file request timeout : {_requestURL}");
_webRequest.Abort();
_isAbort = true;
}
@@ -236,7 +236,7 @@ namespace YooAsset
/// </summary>
public void ReportError()
{
Logger.Error($"Failed to download : {_requestURL} Error : {_lastError}");
YooLogger.Error($"Failed to download : {_requestURL} Error : {_lastError}");
}
}
}

View File

@@ -158,7 +158,7 @@ namespace YooAsset
/// </summary>
public void ReportError()
{
Logger.Error(_downloadError);
YooLogger.Error(_downloadError);
}

View File

@@ -81,7 +81,7 @@ namespace YooAsset
}
internal override void Start()
{
Logger.Log($"Begine to download : {TotalDownloadCount} files and {TotalDownloadBytes} bytes");
YooLogger.Log($"Begine to download : {TotalDownloadCount} files and {TotalDownloadBytes} bytes");
_steps = ESteps.Loading;
}
internal override void Update()
@@ -174,7 +174,7 @@ namespace YooAsset
{
if (_steps == ESteps.None)
{
OperationUpdater.ProcessOperaiton(this);
OperationSystem.ProcessOperaiton(this);
}
}
}

View File

@@ -128,12 +128,12 @@ namespace YooAsset
PatchCache cache = PatchCache.LoadCache();
if (cache.CacheAppVersion != Application.version)
{
Logger.Warning($"Cache is dirty ! Cache app version is {cache.CacheAppVersion}, Current app version is {Application.version}");
YooLogger.Warning($"Cache is dirty ! Cache app version is {cache.CacheAppVersion}, Current app version is {Application.version}");
// 注意在覆盖安装的时候会保留APP沙盒目录可以选择清空缓存目录
if (_impl.ClearCacheWhenDirty)
{
Logger.Warning("Clear cache files.");
YooLogger.Warning("Clear cache files.");
PatchHelper.DeleteSandboxCacheFolder();
}
@@ -148,7 +148,7 @@ namespace YooAsset
if (_steps == ESteps.LoadAppManifest)
{
// 加载APP内的补丁清单
Logger.Log($"Load application patch manifest.");
YooLogger.Log($"Load application patch manifest.");
string filePath = AssetPathHelper.MakeStreamingLoadPath(ResourceSettingData.Setting.PatchManifestFileName);
_downloadURL = AssetPathHelper.ConvertToWWWPath(filePath);
_downloader = new UnityWebRequester();
@@ -183,7 +183,7 @@ namespace YooAsset
// 加载沙盒内的补丁清单
if (PatchHelper.CheckSandboxPatchManifestFileExist())
{
Logger.Log($"Load sandbox patch manifest.");
YooLogger.Log($"Load sandbox patch manifest.");
string filePath = AssetPathHelper.MakePersistentLoadPath(ResourceSettingData.Setting.PatchManifestFileName);
string jsonData = File.ReadAllText(filePath);
_impl.LocalPatchManifest = PatchManifest.Deserialize(jsonData);

View File

@@ -81,11 +81,11 @@ namespace YooAsset
if (_impl.IgnoreResourceVersion && _updateResourceVersion > 0)
{
Logger.Warning($"Update resource version {_updateResourceVersion} is invalid when ignore resource version.");
YooLogger.Warning($"Update resource version {_updateResourceVersion} is invalid when ignore resource version.");
}
else
{
Logger.Log($"Update patch manifest : update resource version is {_updateResourceVersion}");
YooLogger.Log($"Update patch manifest : update resource version is {_updateResourceVersion}");
}
}
internal override void Update()
@@ -96,7 +96,7 @@ namespace YooAsset
if (_steps == ESteps.LoadWebManifestHash)
{
string webURL = GetPatchManifestRequestURL(_updateResourceVersion, ResourceSettingData.Setting.PatchManifestHashFileName);
Logger.Log($"Beginning to request patch manifest hash : {webURL}");
YooLogger.Log($"Beginning to request patch manifest hash : {webURL}");
_downloaderHash = new UnityWebRequester();
_downloaderHash.SendRequest(webURL, _timeout);
_steps = ESteps.CheckWebManifestHash;
@@ -125,12 +125,12 @@ namespace YooAsset
string currentFileHash = PatchHelper.GetSandboxPatchManifestFileHash();
if (currentFileHash == webManifestHash)
{
Logger.Log($"Patch manifest file hash is not change : {webManifestHash}");
YooLogger.Log($"Patch manifest file hash is not change : {webManifestHash}");
_steps = ESteps.InitPrepareCache;
}
else
{
Logger.Log($"Patch manifest hash is change : {webManifestHash} -> {currentFileHash}");
YooLogger.Log($"Patch manifest hash is change : {webManifestHash} -> {currentFileHash}");
_steps = ESteps.LoadWebManifest;
}
}
@@ -138,7 +138,7 @@ namespace YooAsset
if (_steps == ESteps.LoadWebManifest)
{
string webURL = GetPatchManifestRequestURL(_updateResourceVersion, ResourceSettingData.Setting.PatchManifestFileName);
Logger.Log($"Beginning to request patch manifest : {webURL}");
YooLogger.Log($"Beginning to request patch manifest : {webURL}");
_downloaderManifest = new UnityWebRequester();
_downloaderManifest.SendRequest(webURL, _timeout);
_steps = ESteps.CheckWebManifest;
@@ -179,7 +179,7 @@ namespace YooAsset
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
float costTime = UnityEngine.Time.realtimeSinceStartup - _verifyTime;
Logger.Log($"Verify files total time : {costTime}");
YooLogger.Log($"Verify files total time : {costTime}");
}
}
}
@@ -205,7 +205,7 @@ namespace YooAsset
_impl.LocalPatchManifest = PatchManifest.Deserialize(content);
// 注意:这里会覆盖掉沙盒内的补丁清单文件
Logger.Log("Save remote patch manifest file.");
YooLogger.Log("Save remote patch manifest file.");
string savePath = AssetPathHelper.MakePersistentLoadPath(ResourceSettingData.Setting.PatchManifestFileName);
PatchManifest.Serialize(savePath, _impl.LocalPatchManifest);
}
@@ -276,7 +276,7 @@ namespace YooAsset
}
else
{
Logger.Warning("Failed to run verify thread.");
YooLogger.Warning("Failed to run verify thread.");
break;
}
}

View File

@@ -3,7 +3,7 @@
namespace YooAsset
{
[Serializable]
public class PatchAsset
internal class PatchAsset
{
/// <summary>
/// 资源路径

View File

@@ -1,11 +1,10 @@
using System;
using System.Linq;
using YooAsset.Utility;
namespace YooAsset
{
[Serializable]
public class PatchBundle
internal class PatchBundle
{
/// <summary>
/// 资源包名称

View File

@@ -2,7 +2,6 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using YooAsset.Utility;
namespace YooAsset
{
@@ -22,14 +21,14 @@ namespace YooAsset
{
if (PatchHelper.CheckSandboxCacheFileExist())
{
Logger.Log("Load patch cache from disk.");
YooLogger.Log("Load patch cache from disk.");
string filePath = PatchHelper.GetSandboxCacheFilePath();
string jsonData = FileUtility.ReadFile(filePath);
return JsonUtility.FromJson<PatchCache>(jsonData);
}
else
{
Logger.Log($"Create patch cache to disk : {Application.version}");
YooLogger.Log($"Create patch cache to disk : {Application.version}");
PatchCache cache = new PatchCache();
cache.CacheAppVersion = Application.version;
string filePath = PatchHelper.GetSandboxCacheFilePath();
@@ -44,7 +43,7 @@ namespace YooAsset
/// </summary>
public static void UpdateCache()
{
Logger.Log($"Update patch cache to disk : {Application.version}");
YooLogger.Log($"Update patch cache to disk : {Application.version}");
PatchCache cache = new PatchCache();
cache.CacheAppVersion = Application.version;
string filePath = PatchHelper.GetSandboxCacheFilePath();

View File

@@ -1,6 +1,5 @@
using System.IO;
using System.Text;
using YooAsset.Utility;
namespace YooAsset
{

View File

@@ -3,7 +3,6 @@ using System.IO;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using YooAsset.Utility;
namespace YooAsset
{
@@ -11,7 +10,7 @@ namespace YooAsset
/// 补丁清单文件
/// </summary>
[Serializable]
public class PatchManifest
internal class PatchManifest
{
/// <summary>
/// 资源版本号
@@ -79,7 +78,7 @@ namespace YooAsset
}
else
{
Logger.Warning($"Not found asset path in patch manifest : {assetPath}");
YooLogger.Warning($"Not found asset path in patch manifest : {assetPath}");
return new string[] { };
}
}
@@ -104,7 +103,7 @@ namespace YooAsset
}
else
{
Logger.Warning($"Not found asset path in patch manifest : {assetPath}");
YooLogger.Warning($"Not found asset path in patch manifest : {assetPath}");
return string.Empty;
}
}
@@ -150,7 +149,7 @@ namespace YooAsset
{
string assetPathWithoutExtension = StringUtility.RemoveExtension(assetPath);
if (patchManifest.Assets.ContainsKey(assetPathWithoutExtension))
Logger.Warning($"Asset path have existed : {assetPathWithoutExtension}");
YooLogger.Warning($"Asset path have existed : {assetPathWithoutExtension}");
else
patchManifest.Assets.Add(assetPathWithoutExtension, patchAsset);
}

View File

@@ -12,7 +12,7 @@ namespace YooAsset
public InitializationOperation InitializeAsync()
{
var operation = new EditorModeInitializationOperation();
OperationUpdater.ProcessOperaiton(operation);
OperationSystem.ProcessOperaiton(operation);
return operation;
}
@@ -27,7 +27,7 @@ namespace YooAsset
#region IBundleServices接口
BundleInfo IBundleServices.GetBundleInfo(string bundleName)
{
Logger.Warning($"Editor play mode can not get bundle info.");
YooLogger.Warning($"Editor play mode can not get bundle info.");
BundleInfo bundleInfo = new BundleInfo(bundleName, bundleName);
return bundleInfo;
}

View File

@@ -28,7 +28,7 @@ namespace YooAsset
_fallbackHostServer = fallbackHostServer;
var operation = new HostPlayModeInitializationOperation(this);
OperationUpdater.ProcessOperaiton(operation);
OperationSystem.ProcessOperaiton(operation);
return operation;
}
@@ -38,7 +38,7 @@ namespace YooAsset
public UpdateManifestOperation UpdatePatchManifestAsync(int updateResourceVersion, int timeout)
{
var operation = new HostPlayModeUpdateManifestOperation(this, updateResourceVersion, timeout);
OperationUpdater.ProcessOperaiton(operation);
OperationSystem.ProcessOperaiton(operation);
return operation;
}
@@ -284,7 +284,7 @@ namespace YooAsset
}
else
{
Logger.Warning($"Not found bundle in patch manifest : {bundleName}");
YooLogger.Warning($"Not found bundle in patch manifest : {bundleName}");
BundleInfo bundleInfo = new BundleInfo(bundleName, string.Empty);
return bundleInfo;
}

View File

@@ -14,7 +14,7 @@ namespace YooAsset
public InitializationOperation InitializeAsync()
{
var operation = new OfflinePlayModeInitializationOperation(this);
OperationUpdater.ProcessOperaiton(operation);
OperationSystem.ProcessOperaiton(operation);
return operation;
}
@@ -42,7 +42,7 @@ namespace YooAsset
}
else
{
Logger.Warning($"Not found bundle in patch manifest : {bundleName}");
YooLogger.Warning($"Not found bundle in patch manifest : {bundleName}");
BundleInfo bundleInfo = new BundleInfo(bundleName, string.Empty);
return bundleInfo;
}