热更流程完成

This commit is contained in:
2025-11-03 17:46:28 +08:00
parent 75fb982872
commit db6f5d147e
43 changed files with 2596 additions and 326 deletions

View File

@@ -586,6 +586,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
MainUICanvas: {fileID: 1171471944}
UICamera: {fileID: 124489897}
MainCamera: {fileID: 330585545}
PlayMode: 2
--- !u!4 &1019312449
Transform:
@@ -602,6 +603,81 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1144573926
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1144573927}
- component: {fileID: 1144573929}
- component: {fileID: 1144573928}
m_Layer: 5
m_Name: InitBg
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1144573927
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1144573926}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1171471948}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1144573928
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1144573926}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0, g: 0, b: 0, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &1144573929
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1144573926}
m_CullTransparentMesh: 1
--- !u!1 &1171471944
GameObject:
m_ObjectHideFlags: 0
@@ -695,7 +771,8 @@ RectTransform:
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_ConstrainProportionsScale: 0
m_Children: []
m_Children:
- {fileID: 1144573927}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}

View File

@@ -1,4 +1,4 @@
using UnityEditor;
using UnityEditor;
using UnityEngine;
using YooAsset.Editor;
using YooAsset;

View File

@@ -1,4 +1,4 @@
using System.Collections;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
@@ -43,7 +43,7 @@ public class CopyHotDll
HybridCLR.Editor.Commands.CompileDllCommand.CompileDllActiveBuildTarget();
string sourceDir = $"{Application.dataPath.Replace("/Assets", "")}/HybridCLRData/AssembliesPostIl2CppStrip/{UnityEditor.EditorUserBuildSettings.activeBuildTarget}/";
string destDir = $"{Application.dataPath}/GameRes/Main/HotUpdateDll/";
foreach (string dll in Boot.Inst.DepDlls)
foreach (string dll in HotDllLoader.Inst.DepDlls)
{
string sourcePath = $"{sourceDir}/{dll}";
string destPath = $"{destDir}/{dll}.bytes";

View File

@@ -1,18 +1,14 @@
using Cysharp.Threading.Tasks;
using System.Collections.Generic;
using UnityEngine;
using YooAsset;
using static UnityEngine.Rendering.VirtualTexturing.Debugging;
public class Boot : SingletonMono<Boot>
public class Boot : MonoBehaviour
{
public List<string> DepDlls = new List<string>()
{
"mscorlib.dll",
"System.dll",
"System.Core.dll",
"Mirror.dll"
};
public GameObject MainUICanvas;
public Camera UICamera;
public Camera MainCamera;
public EPlayMode PlayMode = EPlayMode.EditorSimulateMode;
void Awake()
{
@@ -21,6 +17,9 @@ public class Boot : SingletonMono<Boot>
#endif
Application.targetFrameRate = 60;
Application.runInBackground = true;
DontDestroyOnLoad(MainUICanvas);
DontDestroyOnLoad(UICamera);
DontDestroyOnLoad(MainCamera);
}
async void Start()
{
@@ -28,10 +27,14 @@ public class Boot : SingletonMono<Boot>
GameManager.Inst.MainUICanvas = MainUICanvas;
bool updateSuccess = await PatchManager.Inst.StartOperation(PlayMode);
if (updateSuccess)
EnterGame();
await EnterGame();
}
private void EnterGame()
private async UniTask EnterGame()
{
Debug.Log("EnterGame");
var assetHandle = YooAssets.TryGetPackage("Main").LoadSceneAsync("Test");
await assetHandle.ToUniTask();
if (assetHandle.Status == EOperationStatus.Succeed)
assetHandle.ActivateScene();
}
}

View File

@@ -1,3 +1,4 @@
using Cysharp.Threading.Tasks;
using HybridCLR;
using System.Collections.Generic;
using System.Linq;
@@ -7,26 +8,34 @@ using YooAsset;
public class HotDllLoader : Singleton<HotDllLoader>
{
public void LoadDll(ResourcePackage package, string dll)
public List<string> DepDlls = new List<string>()
{
"mscorlib.dll",
"System.dll",
"System.Core.dll",
};
public async UniTask LoadDll(ResourcePackage package, string dll)
{
if (package.GetAssetInfo(dll).Error == string.Empty)
{
AssetHandle handle = package.LoadAssetSync<TextAsset>(dll);
AssetHandle handle = package.LoadAssetAsync<TextAsset>(dll);
await handle.ToUniTask();
#if UNITY_EDITOR
Assembly hotUpdateAss = System.AppDomain.CurrentDomain.GetAssemblies().First(a => a.GetName().Name == dll.Replace(".dll", ""));
#else
Assembly hotUpdateAss = Assembly.Load((handle.AssetObject as TextAsset).bytes);
#endif
Debug.Log($"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>{dll}");
Debug.Log($"加载{dll}");
}
}
public void LoadDepDll(ResourcePackage package, List<string> dlls)
public async UniTask LoadDepDll(ResourcePackage package)
{
foreach (string dll in dlls)
foreach (string dll in DepDlls)
{
if (package.GetAssetInfo(dll).Error == string.Empty)
{
AssetHandle handle = package.LoadAssetSync<TextAsset>(dll);
AssetHandle handle = package.LoadAssetAsync<TextAsset>(dll);
await handle.ToUniTask();
RuntimeApi.LoadMetadataForAOTAssembly((handle.AssetObject as TextAsset).bytes, HomologousImageMode.SuperSet);
}
}

View File

@@ -26,122 +26,38 @@ public class MainOperation
public async UniTask Execute()
{
PatchEvent.UpdateProgress(0f);
InitializationOperation initializationOperation = await operation.InitializePackage();
//<2F><>ʼ<EFBFBD><CABC>ʧ<EFBFBD><CAA7>
if (initializationOperation.Status != EOperationStatus.Succeed)
{
MessageBox.Show()
.SetTitle(operation.data.packageName)
.SetContent($"{initializationOperation.Error}")
.AddButton("<22>˳<EFBFBD>", (box) => { Application.Quit(); });
return;
}
PatchEvent.UpdateStatus($"<22><>ʼ<EFBFBD><CABC><EFBFBD>ɹ<EFBFBD>{operation.data.packageName}");
Debug.Log($"<22><>ʼ<EFBFBD><CABC><EFBFBD>ɹ<EFBFBD>{operation.data.packageName}");
var PackageVersionOperation = await operation.RequestPackageVersion();
if (PackageVersionOperation.Status != EOperationStatus.Succeed)
{
MessageBox.Show()
.SetTitle(operation.data.packageName)
.SetContent($"{PackageVersionOperation.Error}")
.AddButton("<22>˳<EFBFBD>", (box) => { Application.Quit(); });
return;
}
operation.packageVersion = PackageVersionOperation.PackageVersion;
PatchEvent.UpdateStatus($"<22><>ȡ<EFBFBD><EFBFBD>ɹ<EFBFBD>{operation.data.packageName}");
Debug.Log($"<22><>ȡ<EFBFBD><EFBFBD>ɹ<EFBFBD>{operation.data.packageName}<7D><>{operation.packageVersion}");
var PackageManifestOperation = await operation.UpdatePackageManifest();
if (PackageManifestOperation.Status != EOperationStatus.Succeed)
{
MessageBox.Show()
.SetTitle(operation.data.packageName)
.SetContent($"{PackageManifestOperation.Error}")
.AddButton("<22>˳<EFBFBD>", (box) => { Application.Quit(); });
return;
}
var DownloaderOperation = operation.CreateDownloader();
if (DownloaderOperation.TotalDownloadCount == 0)
{
operation.SaveVersionToCache();
PatchEvent.UpdateStatus($"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>{operation.data.packageName}");
Debug.Log($"<22><><EFBFBD><EFBFBD>{operation.data.packageName}<7D><><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD><E6B1BE>{operation.packageVersion}");
return;
}
else
if (!await operation.InitializePackage()) return;
if (!await operation.RequestPackageVersion()) return;
if (!await operation.UpdatePackageManifest()) return;
if (operation.CreateDownloader())
{
if (autoDownload)
{
if (!await Download(DownloaderOperation)) return;
if (!await operation.DownloadPackageFiles()) return;
}
else
{
var completionSource = new UniTaskCompletionSource<bool>();
MessageBox.Show()
.SetTitle(operation.data.packageName)
.SetContent($"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>\n{operation.GetCachedPackageVersion()}=>{operation.packageVersion}: {DownloaderOperation.TotalDownloadBytes / 1024f / 1024f:F1}MB")
.AddButton("<22><><EFBFBD><EFBFBD>", async (box) =>
{
bool success = await Download(DownloaderOperation);
completionSource.TrySetResult(success);
})
.AddButton("<22><><EFBFBD><EFBFBD>", (box) =>
{
DownloaderOperation.CancelDownload();
completionSource.TrySetResult(true);
})
.AddButton("<22>˳<EFBFBD>", (box) =>
{
completionSource.TrySetResult(false);
Application.Quit();
});
bool shouldContinue = await completionSource.Task;
if (!shouldContinue) return;
if (!await operation.CheckDownloadOrSkip()) return;
}
var ClearCacheFilesOperation = await operation.ClearCacheBundle();
if (ClearCacheFilesOperation.Status != EOperationStatus.Succeed)
{
MessageBox.Show()
.SetTitle(operation.data.packageName)
.SetContent($"{ClearCacheFilesOperation.Error}")
.AddButton("<22>˳<EFBFBD>", (box) => { Application.Quit(); });
return;
}
if (!await operation.ClearCacheBundle()) return;
operation.SaveVersionToCache();
PatchEvent.UpdateStatus($"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>{operation.data.packageName}");
Debug.Log($"<22><><EFBFBD><EFBFBD>{operation.data.packageName}<7D><><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD><E6B1BE>{operation.packageVersion}");
}
}
public async UniTask<bool> Download(DownloaderOperation downloaderOperation)
{
if (!await operation.DownloadPackageFiles())
{
MessageBox.Show()
.SetTitle(operation.data.packageName)
.SetContent($"{downloaderOperation.Error}")
.AddButton("<22>˳<EFBFBD>", (box) => { Application.Quit(); });
return false;
}
return true;
}
private void OnDownloadUpdate(DownloadUpdateData downloadUpdateData)
{
float progress = (float)downloadUpdateData.CurrentDownloadBytes / downloadUpdateData.TotalDownloadBytes;
string sizeText = $"{(downloadUpdateData.CurrentDownloadBytes / 1024f / 1024f):F1}MB / {(downloadUpdateData.TotalDownloadBytes / 1024f / 1024f):F1}MB";
PatchEvent.UpdateProgress(progress);
PatchEvent.UpdateDownloadSize(sizeText);
PatchEvent.UpdateStatus($"{data.packageName} <EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...");
PatchEvent.UpdateStatus($"{data.packageName} 资源下载中...");
}
private void OnDownloadFinish(DownloaderFinishData downloaderFinishData)
{
PatchEvent.UpdateStatus("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
PatchEvent.UpdateStatus("下载完成");
}
private void OnDownloadError(DownloadErrorData downloadErrorData)
{
PatchEvent.UpdateStatus($"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>:{downloadErrorData.FileName}\n{downloadErrorData.ErrorInfo}");
PatchEvent.UpdateStatus($"下载失败:{downloadErrorData.FileName}\n{downloadErrorData.ErrorInfo}");
}
}

View File

@@ -11,6 +11,8 @@ public class PatchManager : Singleton<PatchManager>
MainOperation _mainOperation = new MainOperation(playMode);
await _mainOperation.Execute();
await HotDllLoader.Inst.LoadDepDll(YooAssets.GetPackage("Main"));
await HotDllLoader.Inst.LoadDll(YooAssets.GetPackage("Main"), "GameScripts.Main");
return true;
}

View File

@@ -28,8 +28,8 @@ public class PatchOperation
this.data = data;
PkgVersionKey = $"{Application.productName}_{data.packageName}";
}
#region <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public async UniTask<InitializationOperation> InitializePackage()
#region
public async UniTask<bool> InitializePackage()
{
package = YooAssets.TryGetPackage(data.packageName);
if (package == null)
@@ -56,7 +56,19 @@ public class PatchOperation
break;
}
await initializationOperation.ToUniTask();
return initializationOperation;
if (initializationOperation.Status != EOperationStatus.Succeed)
{
MessageBox.Show()
.SetTitle($"{data.packageName}初始化")
.SetContent($"{initializationOperation.Error}")
.AddButton("退出", (box) => { Application.Quit(); });
}
else
{
PatchEvent.UpdateStatus($"初始化成功{data.packageName}");
Debug.Log($"初始化成功{data.packageName}");
}
return initializationOperation.Status == EOperationStatus.Succeed;
}
private InitializationOperation InitializeEditorMode(ResourcePackage package)
{
@@ -79,14 +91,14 @@ public class PatchOperation
FileSystemParameters buildinFileSystemParams = null;
if (data.useBuildinFileSystem)
{
// ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD>COPY_BUILDIN_PACKAGE_MANIFEST<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Գ<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>򿽱<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɳ<EFBFBD><EFBFBD>Ŀ¼
// 注意:设置参数COPY_BUILDIN_PACKAGE_MANIFEST,可以初始化的时候拷贝内置清单到沙盒目录
buildinFileSystemParams = FileSystemParameters.CreateDefaultBuildinFileSystemParameters();
buildinFileSystemParams.AddParameter(FileSystemParametersDefine.COPY_BUILDIN_PACKAGE_MANIFEST, true);
}
string defaultHostServer = GetHostServerURL();
string fallbackHostServer = GetHostServerURL();
IRemoteServices remoteServices = new RemoteServices(defaultHostServer, fallbackHostServer);
// ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD>INSTALL_CLEAR_MODE<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>װ<EFBFBD><EFBFBD>ʱ<EFBFBD>򽫿<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// 注意:设置参数INSTALL_CLEAR_MODE,可以解决覆盖安装的时候将拷贝的内置清单文件清理的问题。
var cacheFileSystemParams = FileSystemParameters.CreateDefaultCacheFileSystemParameters(remoteServices);
cacheFileSystemParams.AddParameter(FileSystemParametersDefine.INSTALL_CLEAR_MODE, EOverwriteInstallClearMode.ClearAllManifestFiles);
@@ -102,7 +114,7 @@ public class PatchOperation
var createParameters = new WebPlayModeParameters();
string defaultHostServer = GetHostServerURL();
string fallbackHostServer = GetHostServerURL();
string packageRoot = $"{WeChatWASM.WX.env.USER_DATA_PATH}/__GAME_FILE_CACHE"; //ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ŀ¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸Ĵ˴<EFBFBD><EFBFBD><EFBFBD>
string packageRoot = $"{WeChatWASM.WX.env.USER_DATA_PATH}/__GAME_FILE_CACHE"; //注意:如果有子目录,请修改此处!
IRemoteServices remoteServices = new RemoteServices(defaultHostServer, fallbackHostServer);
createParameters.WebServerFileSystemParameters = WechatFileSystemCreater.CreateFileSystemParameters(packageRoot, remoteServices);
return package.InitializeAsync(createParameters);
@@ -157,13 +169,29 @@ public class PatchOperation
return $"{_fallbackHostServer}/{fileName}";
}
}
#endregion <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public async UniTask<RequestPackageVersionOperation> RequestPackageVersion()
#endregion
#region
public async UniTask<bool> RequestPackageVersion(bool showBox = true)
{
var operation = package.RequestPackageVersionAsync(true, 1);
var operation = package.RequestPackageVersionAsync(true, 5);
await operation.ToUniTask();
return operation;
if (operation.Status != EOperationStatus.Succeed)
{
if (showBox)
{
MessageBox.Show()
.SetTitle($"{data.packageName}请求版本")
.SetContent($"{operation.Error}")
.AddButton("退出", (box) => { Application.Quit(); });
}
}
else
{
packageVersion = operation.PackageVersion;
PatchEvent.UpdateStatus($"获取版本成功{data.packageName}");
Debug.Log($"获取版本成功{data.packageName}{packageVersion}");
}
return operation.Status == EOperationStatus.Succeed;
}
public async Task<string> GetBuildinPackageVersion()
{
@@ -194,37 +222,101 @@ public class PatchOperation
PlayerPrefs.SetString(PkgVersionKey, packageVersion);
PlayerPrefs.Save();
#endif
PatchEvent.UpdateStatus($"更新完成{data.packageName}");
Debug.Log($"更新{data.packageName}完成,版本号{packageVersion}");
}
public async UniTask<UpdatePackageManifestOperation> UpdatePackageManifest()
public async UniTask<bool> UpdatePackageManifest(bool showBox = true)
{
var operation = package.UpdatePackageManifestAsync(packageVersion,5);
var operation = package.UpdatePackageManifestAsync(packageVersion,10);
await operation.ToUniTask();
return operation;
if (operation.Status != EOperationStatus.Succeed)
{
if (showBox)
{
MessageBox.Show()
.SetTitle($"{data.packageName}更新清单")
.SetContent($"{operation.Error}")
.AddButton("退出", (box) => { Application.Quit(); });
}
#endregion <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public ResourceDownloaderOperation CreateDownloader()
}
else
{
PatchEvent.UpdateStatus($"获取资源清单成功{data.packageName}");
Debug.Log($"获取资源清单成功{data.packageName}");
}
return operation.Status == EOperationStatus.Succeed;
}
#endregion
#region
public bool CreateDownloader()
{
downloader = package.CreateResourceDownloader(data.downloadingMaxNum, data.failedTryAgain);
downloader.DownloadErrorCallback = data.downloadError;
downloader.DownloadFinishCallback = data.downloadFinish;
downloader.DownloadUpdateCallback = data.downloadUpdate;
return downloader;
if (downloader.TotalDownloadCount == 0) return false;
return true;
}
public async UniTask<bool> DownloadPackageFiles()
public async UniTask<bool> CheckDownloadOrSkip()
{
var completionSource = new UniTaskCompletionSource<bool>();
MessageBox.Show()
.SetTitle($"{data.packageName}发现更新")
.SetContent($"发现资源更新\n{GetCachedPackageVersion()}=>{packageVersion}: {downloader.TotalDownloadBytes / 1024f / 1024f:F1}MB")
.AddButton("下载", async (box) =>
{
bool success = await DownloadPackageFiles();
completionSource.TrySetResult(success);
})
.AddButton("跳过", (box) =>
{
downloader.CancelDownload();
completionSource.TrySetResult(true);
})
.AddButton("退出", (box) =>
{
completionSource.TrySetResult(false);
Application.Quit();
});
bool shouldContinue = await completionSource.Task;
return shouldContinue;
}
public async UniTask<bool> DownloadPackageFiles(bool showBox = true)
{
if (downloader.TotalDownloadCount == 0)
return true;
Debug.Log($"{data.packageName} DownloadPackageFiles {downloader.TotalDownloadCount}");
downloader.BeginDownload();
await downloader.ToUniTask();
if (downloader.Status != EOperationStatus.Succeed)
{
if (showBox)
{
MessageBox.Show()
.SetTitle($"{data.packageName}下载文件")
.SetContent($"{downloader.Error}")
.AddButton("退出", (box) => { Application.Quit(); });
}
return false;
}
return downloader.Status == EOperationStatus.Succeed;
}
public async UniTask<ClearCacheFilesOperation> ClearCacheBundle()
public async UniTask<bool> ClearCacheBundle(bool showBox = true)
{
var operation = package.ClearCacheFilesAsync(EFileClearMode.ClearUnusedBundleFiles);
await operation.ToUniTask();
return operation;
if (operation.Status != EOperationStatus.Succeed)
{
if (showBox)
{
MessageBox.Show()
.SetTitle($"{data.packageName}清除缓存")
.SetContent($"{operation.Error}")
.AddButton("退出", (box) => { Application.Quit(); });
}
#endregion <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
return operation.Status == EOperationStatus.Succeed;
}
#endregion
}

View File

@@ -23,46 +23,27 @@ public class PreloadOperation
#if !UNITY_EDITOR
CheckIsOffline();
#endif
InitializationOperation initializationOperation = await operation.InitializePackage();
//<2F><>ʼ<EFBFBD><CABC>ʧ<EFBFBD><CAA7>
if (initializationOperation.Status != EOperationStatus.Succeed)
{
MessageBox.Show()
.SetTitle(operation.data.packageName)
.SetContent($"{initializationOperation.Error}")
.AddButton("<22>˳<EFBFBD>", (box) => { Application.Quit(); });
return;
}
Debug.Log($"<22><>ʼ<EFBFBD><CABC><EFBFBD>ɹ<EFBFBD>{operation.data.packageName}");
if (!await operation.InitializePackage()) return;
var version = await GetBestPackageVersion();
#if UNITY_EDITOR
var PackageVersionOperation = await operation.RequestPackageVersion();
version = PackageVersionOperation.PackageVersion;
if (!await operation.RequestPackageVersion()) return;
version = operation.packageVersion;
#endif
//<EFBFBD><EFBFBD>ȡ<EFBFBD>汾ʧ<EFBFBD><EFBFBD>
//获取版本失败
if (version == null)
{
MessageBox.Show()
.SetTitle(operation.data.packageName)
.SetContent("<EFBFBD><EFBFBD>ȡ<EFBFBD>汾ʧ<EFBFBD><EFBFBD>")
.AddButton("<EFBFBD>˳<EFBFBD>", (box) => { Application.Quit(); });
.SetTitle($"{operation.data.packageName}获取版本")
.SetContent("获取版本失败")
.AddButton("退出", (box) => { Application.Quit(); });
return;
}
operation.packageVersion = version;
Debug.Log($"<22><>ȡ<EFBFBD><EFBFBD>ɹ<EFBFBD>{operation.data.packageName}<7D><>{version}");
UpdatePackageManifestOperation updatePackageManifest = await operation.UpdatePackageManifest();
//<2F><>ȡ<EFBFBD><C8A1>Դ<EFBFBD>嵥ʧ<E5B5A5><CAA7>
if (updatePackageManifest.Status != EOperationStatus.Succeed)
{
MessageBox.Show()
.SetTitle(operation.data.packageName)
.SetContent(updatePackageManifest.Error)
.AddButton("<22>˳<EFBFBD>", (box) => { Application.Quit(); });
return;
}
if (!await operation.UpdatePackageManifest()) return;
await HotDllLoader.Inst.LoadDll(YooAssets.GetPackage("Preload"), "GameScripts.Preload");
await LoadAndShowPatchWindow();
GameManager.Inst.MainUICanvas.transform.Find("InitBg").gameObject.SetActive(false);
_ = UpdatePreloadPackage();
}
void CheckIsOffline()
{
@@ -91,41 +72,17 @@ public class PreloadOperation
await assetHandle.ToUniTask();
if (assetHandle.Status == EOperationStatus.Succeed)
GameObject.Instantiate(assetHandle.AssetObject, GameManager.Inst.MainUICanvas.transform);
Debug.Log("创建热更信息界面");
}
private async UniTask UpdatePreloadPackage()
{
var PackageVersionOperation = await operation.RequestPackageVersion();
if (PackageVersionOperation.Status != EOperationStatus.Succeed)
if (!await operation.RequestPackageVersion(false)) return;
if (!await operation.UpdatePackageManifest(false)) return;
if (operation.CreateDownloader())
{
Debug.Log($"{operation.data.packageName}<7D><>̨<EFBFBD><CCA8><EFBFBD>°汾ʧ<E6B1BE>ܣ<EFBFBD>{PackageVersionOperation.Error}");
return;
if (!await operation.DownloadPackageFiles()) return;
}
operation.packageVersion = PackageVersionOperation.PackageVersion;
var PackageManifestOperation = await operation.UpdatePackageManifest();
if (PackageManifestOperation.Status != EOperationStatus.Succeed)
{
Debug.Log($"{operation.data.packageName}<7D><>̨<EFBFBD><CCA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD>嵥ʧ<E5B5A5>ܣ<EFBFBD>{PackageManifestOperation.Error}");
return;
}
var DownloaderOperation = operation.CreateDownloader();
if(DownloaderOperation.TotalDownloadCount == 0)
{
if (!await operation.ClearCacheBundle()) return;
operation.SaveVersionToCache();
Debug.Log($"<22><>̨<EFBFBD><CCA8><EFBFBD><EFBFBD>{operation.data.packageName}<7D><><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD><E6B1BE>{operation.packageVersion}");
return;
}
if (!await operation.DownloadPackageFiles())
{
Debug.Log($"{operation.data.packageName}<7D><>̨<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>");
return;
}
var ClearCacheFilesOperation = await operation.ClearCacheBundle();
if (ClearCacheFilesOperation.Status != EOperationStatus.Succeed)
{
Debug.Log($"{operation.data.packageName}<7D><>̨<EFBFBD><CCA8><EFBFBD><EFBFBD>δʹ<CEB4>û<EFBFBD><C3BB><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>{ClearCacheFilesOperation.Error}");
return;
}
operation.SaveVersionToCache();
Debug.Log($"<22><>̨<EFBFBD><CCA8><EFBFBD><EFBFBD>{operation.data.packageName}<7D><><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD><E6B1BE>{operation.packageVersion}");
}
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 8c07d0b52b2a26944a48aca72126c671
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 36e76e39e45a7414896ee4f421edd742
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 2d81b0dd854a8df4bb3798f0f4652701
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 51427ea829fb65a4d93a038908ca4223
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -119,6 +119,114 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &462509699
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 462509703}
- component: {fileID: 462509702}
- component: {fileID: 462509701}
- component: {fileID: 462509700}
m_Layer: 0
m_Name: Cube
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!65 &462509700
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 462509699}
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_IsTrigger: 0
m_ProvidesContacts: 0
m_Enabled: 1
serializedVersion: 3
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!23 &462509701
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 462509699}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_SmallMeshCulling: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!33 &462509702
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 462509699}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &462509703
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 462509699}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1171561947
GameObject:
m_ObjectHideFlags: 0
@@ -216,101 +324,9 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &1427946519
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1427946522}
- component: {fileID: 1427946521}
- component: {fileID: 1427946520}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &1427946520
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1427946519}
m_Enabled: 1
--- !u!20 &1427946521
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1427946519}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_Iso: 200
m_ShutterSpeed: 0.005
m_Aperture: 16
m_FocusDistance: 10
m_FocalLength: 50
m_BladeCount: 5
m_Curvature: {x: 2, y: 11}
m_BarrelClipping: 0.25
m_Anamorphism: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_TargetEye: 3
m_HDR: 1
m_AllowMSAA: 1
m_AllowDynamicResolution: 0
m_ForceIntoRT: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: 0.022
--- !u!4 &1427946522
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1427946519}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1660057539 &9223372036854775807
SceneRoots:
m_ObjectHideFlags: 0
m_Roots:
- {fileID: 1427946522}
- {fileID: 1171561949}
- {fileID: 462509703}

View File

@@ -619,7 +619,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &6603670838871176784
RectTransform:
m_ObjectHideFlags: 0
@@ -660,7 +660,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Color: {r: 1, g: 1, b: 1, a: 0.023529412}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1

View File

@@ -12,16 +12,7 @@ VideoClipImporter:
flipVertical: 0
flipHorizontal: 0
importAudio: 1
targetSettings:
:
enableTranscoding: 1
codec: 0
resizeFormat: 0
aspectRatio: 0
customWidth: 1560
customHeight: 720
bitrateMode: 2
spatialQuality: 2
targetSettings: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,3 @@
{
"name": "GameScripts.Main"
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a5014882eef2429488110feb660bef0a
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
using UnityEngine;
public class GameStart : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e78850d2b34a8e74da183b8235948929

View File

@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<root Version="v2025.8.28">
<Common ShowPackageView="True" ShowEditorAlias="False" UniqueBundleName="True" />
<Package PackageName="Preload" PackageDesc="预加载资源" AutoAddressable="True" SupportExtensionless="False" LocationToLower="False" IncludeAssetGUID="False" IgnoreRuleName="NormalIgnoreRule">
<Package PackageName="Preload" PackageDesc="预加载资源" AutoAddressable="True" SupportExtensionless="True" LocationToLower="False" IncludeAssetGUID="False" IgnoreRuleName="NormalIgnoreRule">
<Group GroupActiveRule="EnableGroup" GroupName="UI" GroupDesc="" AssetTags="">
<Collector CollectPath="Assets/GameRes/Preload/UI" CollectGUID="aa8e3d4d97e854440b55d59ed0802eb7" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
<Collector CollectPath="Assets/GameRes/Preload/UI" CollectGUID="" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
</Group>
<Group GroupActiveRule="EnableGroup" GroupName="HotUpdateDll" GroupDesc="" AssetTags="">
<Collector CollectPath="Assets/GameRes/Preload/HotUpdateDll" CollectGUID="4637316722ac8274c9c67684dad27c05" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
</Group>
</Package>
<Package PackageName="Main" PackageDesc="主要资源" AutoAddressable="False" SupportExtensionless="True" LocationToLower="False" IncludeAssetGUID="False" IgnoreRuleName="NormalIgnoreRule">
<Package PackageName="Main" PackageDesc="主要资源" AutoAddressable="True" SupportExtensionless="True" LocationToLower="False" IncludeAssetGUID="False" IgnoreRuleName="NormalIgnoreRule">
<Group GroupActiveRule="EnableGroup" GroupName="Scenes" GroupDesc="" AssetTags="">
<Collector CollectPath="Assets/GameRes/Main/Scenes" CollectGUID="1a9ac131d48956946937843c2007bf95" CollectType="MainAssetCollector" AddressRule="AddressByFileName" PackRule="PackDirectory" FilterRule="CollectAll" UserData="" AssetTags="" />
</Group>

View File

@@ -19,10 +19,10 @@ MonoBehaviour:
- PackageName: Preload
PackageDesc: "\u9884\u52A0\u8F7D\u8D44\u6E90"
EnableAddressable: 1
SupportExtensionless: 0
SupportExtensionless: 1
LocationToLower: 0
IncludeAssetGUID: 0
AutoCollectShaders: 0
AutoCollectShaders: 1
IgnoreRuleName: NormalIgnoreRule
Groups:
- GroupName: UI
@@ -31,7 +31,7 @@ MonoBehaviour:
ActiveRuleName: EnableGroup
Collectors:
- CollectPath: Assets/GameRes/Preload/UI
CollectorGUID: aa8e3d4d97e854440b55d59ed0802eb7
CollectorGUID:
CollectorType: 0
AddressRuleName: AddressByFileName
PackRuleName: PackDirectory
@@ -53,7 +53,7 @@ MonoBehaviour:
UserData:
- PackageName: Main
PackageDesc: "\u4E3B\u8981\u8D44\u6E90"
EnableAddressable: 0
EnableAddressable: 1
SupportExtensionless: 1
LocationToLower: 0
IncludeAssetGUID: 0

View File

@@ -1,10 +1,14 @@
{
"FileVersion": "1.0.0",
"PackageName": "Preload",
"PackageVersion": "2025-11-02-1396",
"PackageVersion": "2025-11-03-1019",
"Wrappers": [
{
"BundleGUID": "e0e69753850939240b54391637fd4391",
"BundleGUID": "49ac1e3d3d58ae8797777760ef1fecda",
"FileName": "preload_assets_gameres_preload_hotupdatedll.bundle"
},
{
"BundleGUID": "3ce7812253782ee2be68e7e5e0728bc1",
"FileName": "preload_assets_gameres_preload_ui.bundle"
},
{
@@ -12,7 +16,7 @@
"FileName": "preload_share_assets_gameres_preload_audio.bundle"
},
{
"BundleGUID": "39bd4da98452ee222e7631bd31e68a0f",
"BundleGUID": "e24036a5b48aa4b3751a70d40ef8c9bb",
"FileName": "preload_share_assets_gameres_preload_video.bundle"
},
{

View File

@@ -1 +1 @@
2025-11-02-1396
2025-11-03-1019

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 37a89ca16ea04ff488f989cc25f754a6
guid: c58fac8ca6502e74ea659e06fc529c95
DefaultImporter:
externalObjects: {}
userData:

View File

@@ -0,0 +1 @@
083e0aa5

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: d2b89d055e68cec48a56b802000825be
guid: ee4b17a46db391f43aa2c95df5a158a6
DefaultImporter:
externalObjects: {}
userData:

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 9e06194c2c1ba214b87f4cbf989ecf74
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because one or more lines are too long

View File

@@ -5,7 +5,7 @@
"depth": 0,
"source": "git",
"dependencies": {},
"hash": "01754c8fb47bd49697b3428993109e7a972a7968"
"hash": "fcef6dfe8ed715cc60a7618a1d2ad62bcace3a80"
},
"com.tuyoogame.yooasset": {
"version": "2.3.17",

View File

@@ -18,6 +18,7 @@ MonoBehaviour:
il2cppPlusRepoURL: https://gitee.com/focus-creative-games/il2cpp_plus
hotUpdateAssemblyDefinitions:
- {fileID: 5897886265953266890, guid: 921b262766d31374c8fd93ad67954b9c, type: 3}
- {fileID: 5897886265953266890, guid: a5014882eef2429488110feb660bef0a, type: 3}
hotUpdateAssemblies: []
preserveHotUpdateAssemblies: []
hotUpdateDllCompileOutputRootDir: HybridCLRData/HotUpdateDlls