@@ -269,8 +269,6 @@ private object Init(bool server)
269269 SpawnManager . SpawnedObjectsList . Clear ( ) ;
270270 SpawnManager . releasedNetworkObjectIds . Clear ( ) ;
271271 SpawnManager . PendingSpawnObjects . Clear ( ) ;
272- NetworkPoolManager . Pools . Clear ( ) ;
273- NetworkPoolManager . PoolNamesToIndexes . Clear ( ) ;
274272 NetworkSceneManager . registeredSceneNames . Clear ( ) ;
275273 NetworkSceneManager . sceneIndexToString . Clear ( ) ;
276274 NetworkSceneManager . sceneNameToIndex . Clear ( ) ;
@@ -879,13 +877,6 @@ private void HandleIncomingData(uint clientId, byte[] data, int channelId, int t
879877 case MLAPIConstants . MLAPI_SWITCH_SCENE :
880878 if ( IsClient ) InternalMessageHandler . HandleSwitchScene ( clientId , messageStream , channelId ) ;
881879 break ;
882- case MLAPIConstants . MLAPI_SPAWN_POOL_OBJECT :
883- if ( IsClient ) InternalMessageHandler . HandleSpawnPoolObject ( clientId , messageStream , channelId ) ;
884- break ;
885- case MLAPIConstants . MLAPI_DESTROY_POOL_OBJECT :
886- if ( IsClient )
887- InternalMessageHandler . HandleDestroyPoolObject ( clientId , messageStream , channelId ) ;
888- break ;
889880 case MLAPIConstants . MLAPI_CHANGE_OWNER :
890881 if ( IsClient ) InternalMessageHandler . HandleChangeOwner ( clientId , messageStream , channelId ) ;
891882 break ;
@@ -981,15 +972,33 @@ internal void OnClientDisconnectFromServer(uint clientId)
981972 if ( IsServer )
982973 {
983974 if ( ConnectedClients [ clientId ] . PlayerObject != null )
984- Destroy ( ConnectedClients [ clientId ] . PlayerObject . gameObject ) ;
975+ {
976+ if ( SpawnManager . customDestroyHandlers . ContainsKey ( ConnectedClients [ clientId ] . PlayerObject . NetworkedPrefabHash ) )
977+ {
978+ SpawnManager . customDestroyHandlers [ ConnectedClients [ clientId ] . PlayerObject . NetworkedPrefabHash ] ( ConnectedClients [ clientId ] . PlayerObject ) ;
979+ SpawnManager . OnDestroyObject ( ConnectedClients [ clientId ] . PlayerObject . NetworkId , false ) ;
980+ }
981+ else
982+ {
983+ Destroy ( ConnectedClients [ clientId ] . PlayerObject . gameObject ) ;
984+ }
985+ }
985986
986987 for ( int i = 0 ; i < ConnectedClients [ clientId ] . OwnedObjects . Count ; i ++ )
987988 {
988989 if ( ConnectedClients [ clientId ] . OwnedObjects [ i ] != null )
989990 {
990991 if ( ! ConnectedClients [ clientId ] . OwnedObjects [ i ] . DontDestroyWithOwner )
991992 {
992- Destroy ( ConnectedClients [ clientId ] . OwnedObjects [ i ] . gameObject ) ;
993+ if ( SpawnManager . customDestroyHandlers . ContainsKey ( ConnectedClients [ clientId ] . OwnedObjects [ i ] . NetworkedPrefabHash ) )
994+ {
995+ SpawnManager . customDestroyHandlers [ ConnectedClients [ clientId ] . OwnedObjects [ i ] . NetworkedPrefabHash ] ( ConnectedClients [ clientId ] . OwnedObjects [ i ] ) ;
996+ SpawnManager . OnDestroyObject ( ConnectedClients [ clientId ] . OwnedObjects [ i ] . NetworkId , false ) ;
997+ }
998+ else
999+ {
1000+ Destroy ( ConnectedClients [ clientId ] . OwnedObjects [ i ] . gameObject ) ;
1001+ }
9931002 }
9941003 else
9951004 {
0 commit comments