using Cysharp.Threading.Tasks; using ET; using UnityEngine; namespace ET.Client { [Event] public class SceneChangeStart_AddComponent : BEvent { protected override async ETTask OnEvent(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." ); UIHelper.Remove( "Lobby" ); UIHelper.SetVisible( "Loading", false ); await GameObjectPool.Instance.CacheSceneObject( mapInfo.Id ); Log.Debug( $"cache scene object end." ); // 通知等待场景切换的协程 EventSystem.Instance.Publish(); PlayerComponent.Instance.ClientScene().GetComponent().Notify( new Wait_SceneChangeFinish() ); } } }