江苏做网站怎么收费,wordpress的wap插件,外贸商城网站模板,网站还能赚钱吗菜单栏相关#xff1a;ENABLE_DLL选项
ET-ChangeDefine-ADD_ENABLE_DLL/REMOVE_ENABLE_DLL
一般在开发阶段使用Editor时需要关闭ENABLE_DLL选项。该选项关闭时#xff0c;修改脚本之后#xff0c;会直接重新编译所有的代码#xff0c;Editor在运行时会直接使用最…菜单栏相关ENABLE_DLL选项
ET-ChangeDefine-ADD_ENABLE_DLL/REMOVE_ENABLE_DLL
一般在开发阶段使用Editor时需要关闭ENABLE_DLL选项。该选项关闭时修改脚本之后会直接重新编译所有的代码Editor在运行时会直接使用最新的程序集。如果ENABLE_DLL选项是开启的框架启动后会加载之前生成的程序集文件这个文件需要在ET-BuildTool界面生成导致每次需要应用修改都要重新生成程序集文件。
框架解析
框架入口解析
启动流程如下 入口文件为Init之后调用CodeLoader对代码进行加载 如果不是EnableDll模式则直接加载程序集。否则通过AB加载文件之后调用LoadHotfix函数 LoadHotfix会加载程序集并且调用EventSystem根据特性注册对应事件的监听。 之后调用ET.Entry的Start方法。 ET.Entry.Start 进行初始化之后调用FiberManager.Instance.Create 调用FiberInit事件推送对应的EntryEvent事件 推送EntryEvent3EntryEvent3_InitClient接收后推送AppStartInitFinish AppStartInitFinish_CreateLoginUI接收该事件后创建UI场景 UI系统
UI界面的生成流程
ET是通过异步方式创建UI如下方例子调用UIHelper.Create方法指定创建UI的场景UI类型和对应的层级 protected override async ETTask Run(Scene scene, EventType.AppStartInitFinish args){await UIHelper.Create(scene, UIType.UILogin, UILayer.Mid);}
调用scene挂载的UIComponent组件处理Create事件 public static async ETTaskUI Create(Scene scene, string uiType, UILayer uiLayer){return await scene.GetComponentUIComponent().Create(uiType, uiLayer);}
之后会标记有对应UIEvent特性的类处理该事件开始加载资源并生成对应的GameObject [UIEvent(UIType.UILogin)]public class UILoginEvent: AUIEvent{public override async ETTaskUI OnCreate(UIComponent uiComponent, UILayer uiLayer){await uiComponent.DomainScene().GetComponentResourcesLoaderComponent().LoadAsync(UIType.UILogin.StringToAB());GameObject bundleGameObject (GameObject) ResourcesComponent.Instance.GetAsset(UIType.UILogin.StringToAB(), UIType.UILogin);GameObject gameObject UnityEngine.Object.Instantiate(bundleGameObject, UIEventComponent.Instance.GetLayer((int)uiLayer));UI ui uiComponent.AddChildUI, string, GameObject(UIType.UILogin, gameObject);ui.AddComponentUILoginComponent();return ui;}public override void OnRemove(UIComponent uiComponent){ResourcesComponent.Instance.UnloadBundle(UIType.UILogin.StringToAB());}}UI组件解析
以UILogin为例子对应的Prefab实际上只挂载了ReferenceCollectorReferenceCollector负责将结点进行绑定 生成该GameObject之后调用AddComponent [UIEvent(UIType.UILogin)]public class UILoginEvent: AUIEvent{public override async ETTaskUI OnCreate(UIComponent uiComponent, UILayer uiLayer){string assetsName $Assets/Bundles/UI/Demo/{UIType.UILogin}.prefab;GameObject bundleGameObject await uiComponent.Scene().GetComponentResourcesLoaderComponent().LoadAssetAsyncGameObject(assetsName);GameObject gameObject UnityEngine.Object.Instantiate(bundleGameObject, uiComponent.UIGlobalComponent.GetLayer((int)uiLayer));UI ui uiComponent.AddChildUI, string, GameObject(UIType.UILogin, gameObject);ui.AddComponentUILoginComponent();return ui;}public override void OnRemove(UIComponent uiComponent){}}
其中UILoginComponent负责显示对应成员
[ComponentOf(typeof(UI))]
public class UILoginComponent: Entity, IAwake
{public GameObject account;public GameObject password;public GameObject loginBtn;
}
AddComponent之后会调用对应的System这里UILoginComponentSystem就是对应的System在Awake阶段通过ReferenceCollector对UILoginComponent进行了绑定以及实现了对应的UI逻辑
[ObjectSystem]
public class UILoginComponentAwakeSystem : AwakeSystemUILoginComponent
{protected override void Awake(UILoginComponent self){ReferenceCollector rc self.GetParentUI().GameObject.GetComponentReferenceCollector();self.loginBtn rc.GetGameObject(LoginBtn);self.loginBtn.GetComponentButton().onClick.AddListener(() { self.OnLogin(); });self.account rc.GetGameObject(Account);self.password rc.GetGameObject(Password);}
}
场景切换
关于ET的场景切换相关逻辑可以查看
UILobbyComponentSystem处理进入Map的操作先是调用EnterMap异步函数等待EnterMapHelper异步返回后删除界面 //UILobbyComponentSystempublic static async ETTask EnterMap(this UILobbyComponent self){await EnterMapHelper.EnterMapAsync(self.ClientScene());await UIHelper.Remove(self.ClientScene(), UIType.UILobby);}
之后EnterMapHelper会向服务器发起进入Map的请求 //EnterMapHelperpublic static async ETTask EnterMapAsync(Scene clientScene){try{G2C_EnterMap g2CEnterMap await clientScene.GetComponentSessionComponent().Session.Call(new C2G_EnterMap()) as G2C_EnterMap;clientScene.GetComponentPlayerComponent().MyId g2CEnterMap.MyId;// 等待场景切换完成await clientScene.GetComponentObjectWait().WaitWait_SceneChangeFinish();EventSystem.Instance.Publish(clientScene, new EventType.EnterMapFinish());}catch (Exception e){Log.Error(e);} }