SceneChangeStart_AddComponent.cs 1.1 KB

123456789101112131415161718192021222324252627282930
  1. using Cysharp.Threading.Tasks;
  2. namespace ET.Client
  3. {
  4. [Event(SceneType.Client)]
  5. public class SceneChangeStart_AddComponent : AEvent<EventType.SceneChangeStart>
  6. {
  7. protected override async ETTask Run(Scene scene, EventType.SceneChangeStart args)
  8. {
  9. UIHelper.Create("Loading").Coroutine();
  10. var mapInfo = MapConfigCategory.Instance.Get(args.mapId);
  11. var scnName = mapInfo.MapName;
  12. Log.Debug($"loading scene: {scnName}.");
  13. // 加载场景资源 & 加载
  14. var task = await YooAssetProxy.LoadSceneAsync("Scene_" + scnName);
  15. Log.Debug($"scene({task.SceneObject.name}) load finished.");
  16. await TimerComponent.Instance.WaitAsync(1000);
  17. UIHelper.Remove("Lobby");
  18. UIHelper.SetVisible("Loading", false);
  19. await GameObjectPool.Instance.CacheSceneObject(mapInfo.Id);
  20. // 通知等待场景切换的协程
  21. EventSystem.Instance.Publish<EventType.SceneLoadFinish>();
  22. scene.GetComponent<ObjectWait>().Notify(new Wait_SceneChangeFinish());
  23. }
  24. }
  25. }