@@ -390,29 +390,36 @@ await AddressableAssetDownloadManager.Download(
390390 Assets . onSceneDepsFileDownloading . Invoke ,
391391 Assets . onSceneDepsDownloaded . Invoke ,
392392 null ) ;
393- // Load the scene
394- AsyncOperationHandle < SceneInstance > asyncOp = Addressables . LoadSceneAsync (
393+ await AddressableAssetsManager . UnloadAddressableScenes ( ) ;
394+ AsyncOperationHandle < SceneInstance > addressableAsyncOp = Addressables . LoadSceneAsync (
395395 serverSceneInfo . addressableKey ,
396- new LoadSceneParameters ( LoadSceneMode . Single ) ) ;
396+ new LoadSceneParameters ( LoadSceneMode . Single ) , false ) ;
397+ AddressableAssetsManager . AddAddressableSceneHandle ( addressableAsyncOp ) ;
397398 // Wait until scene loaded
398- while ( ! asyncOp . IsDone )
399+ while ( ! addressableAsyncOp . IsDone )
399400 {
400401 await UniTask . Yield ( ) ;
401- float percentageComplete = asyncOp . GetDownloadStatus ( ) . Percent ;
402+ float percentageComplete = addressableAsyncOp . GetDownloadStatus ( ) . Percent ;
402403 Assets . onLoadSceneProgress . Invoke ( serverSceneInfo . sceneName , false , isOnline , percentageComplete ) ;
403404 }
405+ await addressableAsyncOp . Result . ActivateAsync ( ) ;
404406 }
405407 else
406408 {
409+ await AddressableAssetsManager . UnloadAddressableScenes ( ) ;
407410 // Load the scene
408411 AsyncOperation asyncOp = SceneManager . LoadSceneAsync (
409412 serverSceneInfo . sceneName ,
410413 new LoadSceneParameters ( LoadSceneMode . Single ) ) ;
414+ if ( asyncOp != null )
415+ asyncOp . allowSceneActivation = false ;
411416 // Wait until scene loaded
412417 while ( asyncOp != null && ! asyncOp . isDone )
413418 {
414419 await UniTask . Yield ( ) ;
415420 Assets . onLoadSceneProgress . Invoke ( serverSceneInfo . sceneName , false , isOnline , asyncOp . progress ) ;
421+ if ( asyncOp . progress >= 0.9f )
422+ asyncOp . allowSceneActivation = true ;
416423 }
417424 }
418425
@@ -532,13 +539,13 @@ protected override void RegisterMessages()
532539 RegisterClientMessage ( GameMsgTypes . Disconnect , HandleServerDisconnect ) ;
533540 }
534541
535- public async void KickClient ( long connectionId , byte [ ] data )
542+ public async UniTask < bool > KickClient ( long connectionId , byte [ ] data )
536543 {
537544 if ( ! IsServer )
538- return ;
545+ return false ;
539546 ServerSendPacket ( connectionId , 0 , DeliveryMethod . ReliableOrdered , GameMsgTypes . Disconnect , ( writer ) => writer . PutBytesWithLength ( data ) ) ;
540547 await UniTask . Delay ( 500 ) ;
541- ServerTransport . ServerDisconnect ( connectionId ) ;
548+ return ServerTransport . ServerDisconnect ( connectionId ) ;
542549 }
543550
544551 public override void OnPeerConnected ( long connectionId )
0 commit comments