终于到了核心部分之一了——消息机制
既然讲到消息,我们要到消息的源头——客户端
来到Unity.Hotfix的Init文件,并定位到这一句
Game.EventSystem.Run(EventIdType.InitSceneStart);
他会执行这里的Run代码(不知道为何的去复习ETBook的EventSystem哦)
进入UILoginFactory,他是登录UI的工厂类,在这个工厂将完成一系列的操作
//获取资源组件,用以加载资源
ResourcesComponent resourcesComponent = ETModel.Game.Scene.GetComponent<ResourcesComponent>();
//加载UI的AB包
resourcesComponent.LoadBundle(UIType.UILogin.StringToAB());
//获取到登录UI
GameObject bundleGameObject = (GameObject)resourcesComponent.GetAsset(UIType.UILogin.StringToAB(), UIType.UILogin);
//实例化登录UI
GameObject gameObject = UnityEngine.Object.Instantiate(bundleGameObject);
//在组件工厂创建UI(主要是为了能给游戏物体添加