11using MLAPI . MonoBehaviours . Core ;
2+ using System ;
23using System . Collections . Generic ;
34using System . IO ;
45using UnityEngine ;
@@ -170,12 +171,13 @@ internal static void OnSpawnObject(NetworkedObject netObject, int? clientOwnerId
170171 Debug . LogWarning ( "MLAPI: Server only objects does not have to be spawned" ) ;
171172 return ;
172173 }
173- else if ( netManager . NetworkConfig . HandleObjectSpawning )
174+ else if ( ! netManager . NetworkConfig . HandleObjectSpawning )
174175 {
175176 Debug . LogWarning ( "MLAPI: NetworkingConfiguration is set to not handle object spawning" ) ;
176177 return ;
177178 }
178179 uint netId = GetNetworkObjectId ( ) ;
180+ netObject . networkId = netId ;
179181 spawnedObjects . Add ( netId , netObject ) ;
180182 netObject . isSpawned = true ;
181183 if ( clientOwnerId != null )
@@ -192,11 +194,8 @@ internal static void OnSpawnObject(NetworkedObject netObject, int? clientOwnerId
192194 writer . Write ( netObject . OwnerClientId ) ;
193195 writer . Write ( netObject . SpawnablePrefabIndex ) ;
194196 }
195- //If we are host, send to everyone except ourselves. Otherwise, send to all
196- if ( netManager . isHost )
197- netManager . Send ( "MLAPI_ADD_OBJECT" , "MLAPI_INTERNAL" , stream . GetBuffer ( ) , - 1 ) ;
198- else
199- netManager . Send ( "MLAPI_ADD_OBJECT" , "MLAPI_INTERNAL" , stream . GetBuffer ( ) ) ;
197+
198+ netManager . Send ( "MLAPI_ADD_OBJECT" , "MLAPI_INTERNAL" , stream . GetBuffer ( ) ) ;
200199 }
201200 }
202201 }
0 commit comments