@@ -184,11 +184,11 @@ IEnumerator WaitToEndSession()
184
184
SceneLoaderWrapper . Instance . LoadScene ( "BossRoom" , useNetworkSceneManager : true ) ;
185
185
}
186
186
187
- public void OnNetworkDespawn ( )
187
+ void OnNetworkDespawn ( )
188
188
{
189
189
if ( NetworkManager . Singleton )
190
190
{
191
- NetworkManager . Singleton . OnClientDisconnectCallback -= OnClientDisconnectCallback ;
191
+ NetworkManager . Singleton . OnConnectionEvent -= OnConnectionEvent ;
192
192
NetworkManager . Singleton . SceneManager . OnSceneEvent -= OnSceneEvent ;
193
193
}
194
194
if ( networkCharSelection )
@@ -197,15 +197,15 @@ public void OnNetworkDespawn()
197
197
}
198
198
}
199
199
200
- public void OnNetworkSpawn ( )
200
+ void OnNetworkSpawn ( )
201
201
{
202
202
if ( ! NetworkManager . Singleton . IsServer )
203
203
{
204
204
enabled = false ;
205
205
}
206
206
else
207
207
{
208
- NetworkManager . Singleton . OnClientDisconnectCallback += OnClientDisconnectCallback ;
208
+ NetworkManager . Singleton . OnConnectionEvent += OnConnectionEvent ;
209
209
networkCharSelection . OnClientChangedSeat += OnClientChangedSeat ;
210
210
211
211
NetworkManager . Singleton . SceneManager . OnSceneEvent += OnSceneEvent ;
@@ -276,22 +276,25 @@ void SeatNewPlayer(ulong clientId)
276
276
}
277
277
}
278
278
279
- void OnClientDisconnectCallback ( ulong clientId )
279
+ void OnConnectionEvent ( NetworkManager networkManager , ConnectionEventData connectionEventData )
280
280
{
281
- // clear this client's PlayerNumber and any associated visuals (so other players know they're gone).
282
- for ( int i = 0 ; i < networkCharSelection . sessionPlayers . Count ; ++ i )
281
+ if ( connectionEventData . EventType == ConnectionEvent . ClientDisconnected )
283
282
{
284
- if ( networkCharSelection . sessionPlayers [ i ] . ClientId == clientId )
283
+ // clear this client's PlayerNumber and any associated visuals (so other players know they're gone).
284
+ for ( int i = 0 ; i < networkCharSelection . sessionPlayers . Count ; ++ i )
285
285
{
286
- networkCharSelection . sessionPlayers . RemoveAt ( i ) ;
287
- break ;
286
+ if ( networkCharSelection . sessionPlayers [ i ] . ClientId == connectionEventData . ClientId )
287
+ {
288
+ networkCharSelection . sessionPlayers . RemoveAt ( i ) ;
289
+ break ;
290
+ }
288
291
}
289
- }
290
292
291
- if ( ! networkCharSelection . IsSessionClosed . Value )
292
- {
293
- // If the Session is not already closing, close if the remaining players are all ready
294
- CloseSessionIfReady ( ) ;
293
+ if ( ! networkCharSelection . IsSessionClosed . Value )
294
+ {
295
+ // If the Session is not already closing, close if the remaining players are all ready
296
+ CloseSessionIfReady ( ) ;
297
+ }
295
298
}
296
299
}
297
300
}
0 commit comments