123456789101112131415161718192021222324252627282930 |
- using Cysharp.Threading.Tasks;
- namespace ET.Client
- {
- [Event(SceneType.Client)]
- public class SceneChangeStart_AddComponent : AEvent<EventType.SceneChangeStart>
- {
- protected override async ETTask Run(Scene scene, EventType.SceneChangeStart args)
- {
- UIHelper.Create("Loading").Coroutine();
- var mapInfo = MapConfigCategory.Instance.Get(args.mapId);
- var scnName = mapInfo.MapName;
- Log.Debug($"loading scene: {scnName}.");
- // 加载场景资源 & 加载
- var task = await YooAssetProxy.LoadSceneAsync("Scene_" + scnName);
- Log.Debug($"scene({task.SceneObject.name}) load finished.");
- await TimerComponent.Instance.WaitAsync(1000);
- UIHelper.Remove("Lobby");
- UIHelper.SetVisible("Loading", false);
- await GameObjectPool.Instance.CacheSceneObject(mapInfo.Id);
- // 通知等待场景切换的协程
- EventSystem.Instance.Publish<EventType.SceneLoadFinish>();
- scene.GetComponent<ObjectWait>().Notify(new Wait_SceneChangeFinish());
- }
- }
- }
|