@@ -365,6 +365,12 @@ private ConnectionConfig Init()
365
365
/// <param name="netConfig">The NetworkingConfiguration to use</param>
366
366
public void StartServer ( )
367
367
{
368
+ if ( isServer || isClient )
369
+ {
370
+ Debug . LogWarning ( "MLAPI: Cannot start server while an instance is already running" ) ;
371
+ return ;
372
+ }
373
+
368
374
ConnectionConfig cConfig = Init ( ) ;
369
375
if ( NetworkConfig . ConnectionApproval )
370
376
{
@@ -389,6 +395,12 @@ public void StartServer()
389
395
/// <param name="netConfig">The NetworkingConfiguration to use</param>
390
396
public void StartClient ( )
391
397
{
398
+ if ( isServer || isClient )
399
+ {
400
+ Debug . LogWarning ( "MLAPI: Cannot start client while an instance is already running" ) ;
401
+ return ;
402
+ }
403
+
392
404
ConnectionConfig cConfig = Init ( ) ;
393
405
HostTopology hostTopology = new HostTopology ( cConfig , NetworkConfig . MaxConnections ) ;
394
406
hostId = NetworkTransport . AddHost ( hostTopology , 0 , null ) ;
@@ -453,6 +465,11 @@ public void StopClient()
453
465
/// <param name="netConfig">The NetworkingConfiguration to use</param>
454
466
public void StartHost ( )
455
467
{
468
+ if ( isServer || isClient )
469
+ {
470
+ Debug . LogWarning ( "MLAPI: Cannot start host while an instance is already running" ) ;
471
+ return ;
472
+ }
456
473
ConnectionConfig cConfig = Init ( ) ;
457
474
if ( NetworkConfig . ConnectionApproval )
458
475
{
@@ -502,6 +519,7 @@ private void Shutdown()
502
519
isListening = false ;
503
520
_isClient = false ;
504
521
_isServer = false ;
522
+ SpawnManager . DestroyNonSceneObjects ( ) ;
505
523
NetworkTransport . Shutdown ( ) ;
506
524
}
507
525
0 commit comments