|
@@ -12,8 +12,6 @@ namespace ET
|
|
|
{
|
|
|
public class CodeLoader: Singleton<CodeLoader>
|
|
|
{
|
|
|
- private Assembly model;
|
|
|
-
|
|
|
public void Start()
|
|
|
{
|
|
|
if (Define.EnableCodes)
|
|
@@ -27,56 +25,67 @@ namespace ET
|
|
|
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
|
|
Dictionary<string, Type> types = AssemblyHelper.GetAssemblyTypes(assemblies);
|
|
|
EventSystem.Instance.Add(types);
|
|
|
+
|
|
|
+ bool bStart = false;
|
|
|
foreach (Assembly ass in assemblies)
|
|
|
{
|
|
|
string name = ass.GetName().Name;
|
|
|
if (name == "Unity.Model.Codes")
|
|
|
{
|
|
|
- this.model = ass;
|
|
|
- }
|
|
|
+
|
|
|
+ bStart= true;
|
|
|
+ IStaticMethod start = new StaticMethod(ass, "ET.Entry", "Start");
|
|
|
+ start.Run();
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- IStaticMethod start = new StaticMethod(this.model, "ET.Entry", "Start");
|
|
|
- start.Run();
|
|
|
+
|
|
|
+ if(!bStart)
|
|
|
+ {
|
|
|
+ throw new Exception("not found Assembly: 'Unity.Model.Codes'");
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- LoadAssetsAndHotfix().Forget();
|
|
|
- }
|
|
|
+ LoadHotfix();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- private async UniTaskVoid LoadAssetsAndHotfix()
|
|
|
+
|
|
|
+ public void LoadHotfix()
|
|
|
+ {
|
|
|
+ AsyncLoadHotfix().Forget();
|
|
|
+ }
|
|
|
+
|
|
|
+ private async UniTaskVoid AsyncLoadHotfix()
|
|
|
{
|
|
|
|
|
|
await YooAssetProxy.StartYooAssetEngine(YooAssets.EPlayMode.HostPlayMode);
|
|
|
|
|
|
|
|
|
-
|
|
|
+ ShaderVariantCollection shaderVariantCollection =
|
|
|
(await YooAssetProxy.LoadAssetAsync<ShaderVariantCollection>(
|
|
|
YooAssetProxy.GetYooAssetFormatResPath("ProjectSShaderVariant",
|
|
|
YooAssetProxy.YooAssetResType.Shader)))
|
|
|
.GetAssetObject<ShaderVariantCollection>();
|
|
|
-
|
|
|
Stopwatch stopwatch = Stopwatch.StartNew();
|
|
|
shaderVariantCollection.WarmUp();
|
|
|
stopwatch.Stop();
|
|
|
- Log.Info($"Shader Warm Up完成, 耗时: {stopwatch.ElapsedMilliseconds}ms,shaderCount: {shaderVariantCollection.shaderCount} variantCount: {shaderVariantCollection.variantCount}");*/
|
|
|
+ Log.Info($"Shader Warm Up完成, 耗时: {stopwatch.ElapsedMilliseconds}ms,shaderCount: {shaderVariantCollection.shaderCount} variantCount: {shaderVariantCollection.variantCount}");
|
|
|
|
|
|
-#if !UNITY_EDITOR
|
|
|
|
|
|
await LoadMetadataForAOT();
|
|
|
-#endif
|
|
|
- await LoadHotfixCode();
|
|
|
+ await LoadHotfixCode();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
|
|
|
private async UniTask LoadMetadataForAOT()
|
|
|
{
|
|
|
-
|
|
|
- List<string> DLLNameList_ForABLoad = new List<string> (){ } ;
|
|
|
+ HotUpdateAssemblyManifest aotlist = Resources.Load<HotUpdateAssemblyManifest>("HotUpdateAssemblyManifest");
|
|
|
+ var DLLNameList_ForABLoad = aotlist.AOTMetadataDlls;
|
|
|
|
|
|
List<UniTask<RawFileOperation>> tasks = new List<UniTask<RawFileOperation>>();
|
|
|
-
|
|
|
foreach (var aotDll in DLLNameList_ForABLoad)
|
|
|
{
|
|
|
tasks.Add(YooAssetProxy.GetRawFileAsync(aotDll));
|
|
@@ -88,7 +97,7 @@ namespace ET
|
|
|
var ret = RuntimeApi.LoadMetadataForAOTAssembly(task.GetRawBytes(), HomologousImageMode.SuperSet);
|
|
|
if (ret == LoadImageErrorCode.OK)
|
|
|
{
|
|
|
- Log.Info($"LoadMetadataForAOTAssembly({task.GetBundleName()}) ok.");
|
|
|
+ Log.Debug($"LoadMetadataForAOTAssembly({task.GetBundleName()}) ok.");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -97,19 +106,24 @@ namespace ET
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- public async UniTask LoadHotfixCode()
|
|
|
+
|
|
|
+ private async UniTask LoadHotfixCode()
|
|
|
{
|
|
|
- Log.Info("to load hotfix.dll.");
|
|
|
- byte[] assBytes = (await YooAssetProxy.GetRawFileAsync("Code_ProjectS_Hotfix.dll")).GetRawBytes();
|
|
|
- byte[] pdbBytes = (await YooAssetProxy.GetRawFileAsync("Code_ProjectS_Hotfix.pdb")).GetRawBytes();
|
|
|
- var assembly = Assembly.Load(assBytes, pdbBytes);
|
|
|
+ Log.Info("to load model.dll & hotfix.dll.");
|
|
|
+
|
|
|
+ var rawfile_modeldll = await YooAssetProxy.GetRawFileAsync("Model.dll");
|
|
|
+ var rawfile_modelpdb = await YooAssetProxy.GetRawFileAsync("Model.pdb");
|
|
|
+ var modelAssembly = Assembly.Load(rawfile_modeldll.GetRawBytes(), rawfile_modelpdb.GetRawBytes());
|
|
|
+
|
|
|
+ var rawfile_hotfixdll = await YooAssetProxy.GetRawFileAsync("Hotfix.dll");
|
|
|
+ var rawfile_hotfixpdb = await YooAssetProxy.GetRawFileAsync("Hotfix.pdb");
|
|
|
+ var hotfixAssembly = Assembly.Load(rawfile_hotfixdll.GetRawBytes(), rawfile_hotfixpdb.GetRawBytes());
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+ Dictionary<string, Type> types = AssemblyHelper.GetAssemblyTypes(typeof(Game).Assembly, typeof(Init).Assembly, modelAssembly, hotfixAssembly);
|
|
|
+ EventSystem.Instance.Add(types);
|
|
|
|
|
|
Log.Info("to call Client.Entry.");
|
|
|
- IStaticMethod start = new MonoStaticMethod(assembly, "ET.Client.Entry", "Start");
|
|
|
+ IStaticMethod start = new MonoStaticMethod(modelAssembly, "ET.Entry", "Start");
|
|
|
start.Run();
|
|
|
}
|
|
|
}
|