public async CFVoid LoadHotfix() { string assetName = GlobalPath.Hoftix.GetCodeAsset("Code"); LoadAssetCallbacks loadAsset = await CentorPivot.This.GetComponent <ResourceComponent>().LoadAsset(assetName, AssetCategory.Code, GlobalData.AssetPriority.CodeAsset); if (loadAsset.LoadAssetStatus == LoadAssetStatus.Success) { HotfixStart.LoadHotfix((GameObject)loadAsset.Target); m_CurrPreloadCount += 1; } else { Log.Error("加载热更资源失败", LogCategory.Resource); } }
public static void LoadSystem(Assembly assembly = null) { List <Type> ts = HotfixStart.GetHotfixTypes(); types.Clear(); foreach (Type type in ts) { if (type.IsAbstract) { continue; } types.Add(type); } awakeSystems.Clear(); lateUpdateSystems.Clear(); updateSystems.Clear(); startSystems.Clear(); loadSystems.Clear(); changeSystems.Clear(); destroySystems.Clear(); deserializeSystems.Clear(); //foreach (var item in types) //{ // //string X = item.IsAbstract == true ? "ab" : "CALSS"; // //Log.Info("HotfixSystem type" + item.FullName + " IS ABSTRACT: " + X); // if (item.FullName == "DBD.Hotfix.UI.HUIComponentAwakeSystem") // { // object[] attrsX = item.GetCustomAttributes(typeof(HotfixClassAttribute), true); // Log.Info("item type: " + item.FullName + "attrsX.Length" + attrsX.Length); // } //} foreach (Type type in types) { object[] attrs = type.GetCustomAttributes(typeof(AnnotationClassAttribute), true); //Log.Info("HotfixSystem type" + type.FullName + "attrs.Length" + attrs.Length); if (attrs.Length == 0) { continue; } object obj = Activator.CreateInstance(type); switch (obj) { case IAwakeSystem objectSystem: //Log.Info(objectSystem.Type() + " is add"); awakeSystems.Add(objectSystem.Type(), objectSystem); break; case IUpdateSystem updateSystem: updateSystems.Add(updateSystem.Type(), updateSystem); break; case ILateUpdateSystem lateUpdateSystem: lateUpdateSystems.Add(lateUpdateSystem.Type(), lateUpdateSystem); break; case IStartSystem startSystem: startSystems.Add(startSystem.Type(), startSystem); break; case IDestroySystem destroySystem: destroySystems.Add(destroySystem.Type(), destroySystem); break; case ILoadSystem loadSystem: loadSystems.Add(loadSystem.Type(), loadSystem); break; case IChangeSystem changeSystem: changeSystems.Add(changeSystem.Type(), changeSystem); break; case IDeserializeSystem deserializeSystem: deserializeSystems.Add(deserializeSystem.Type(), deserializeSystem); break; } } HotfixEvent.LoadEvent(types); Load(); }