SceneChangeStart_AddComponent.cs 1.4 KB

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