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();
- Scene currentScene = scene.CurrentScene();
- var scnName = currentScene.Name;
- 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);
- currentScene.AddComponent<OperaComponent>();
- await GameObjectPool.Instance.CacheSceneObject();
- // 通知等待场景切换的协程
- EventSystem.Instance.Publish<EventType.SceneLoadFinish>();
- scene.GetComponent<ObjectWait>().Notify(new Wait_SceneChangeFinish());
- }
- }
- }
|