SceneChangeHelper.cs 784 B

123456789101112131415161718
  1. namespace ET.Client
  2. {
  3. public static class SceneChangeHelper
  4. {
  5. // 场景切换协程
  6. public static async ETTask SceneChangeTo(Scene clientScene, MapConfig map, long sceneInstanceId)
  7. {
  8. CurrentScenesComponent currentScenesComponent = clientScene.GetComponent<CurrentScenesComponent>();
  9. currentScenesComponent.Scene?.Dispose(); // 删除之前的CurrentScene,创建新的
  10. SceneFactory.CreateCurrentScene(sceneInstanceId, clientScene.Zone, map.MapName, currentScenesComponent);
  11. // 可以订阅这个事件中创建Loading界面
  12. EventSystem.Instance.Publish(clientScene, new EventType.SceneChangeStart() { mapId = map.Id});
  13. await ETTask.CompletedTask;
  14. }
  15. }
  16. }