1
1
using MLAPI . MonoBehaviours . Core ;
2
+ using System ;
2
3
using System . Collections . Generic ;
3
4
using System . IO ;
4
5
using UnityEngine ;
@@ -170,12 +171,13 @@ internal static void OnSpawnObject(NetworkedObject netObject, int? clientOwnerId
170
171
Debug . LogWarning ( "MLAPI: Server only objects does not have to be spawned" ) ;
171
172
return ;
172
173
}
173
- else if ( netManager . NetworkConfig . HandleObjectSpawning )
174
+ else if ( ! netManager . NetworkConfig . HandleObjectSpawning )
174
175
{
175
176
Debug . LogWarning ( "MLAPI: NetworkingConfiguration is set to not handle object spawning" ) ;
176
177
return ;
177
178
}
178
179
uint netId = GetNetworkObjectId ( ) ;
180
+ netObject . networkId = netId ;
179
181
spawnedObjects . Add ( netId , netObject ) ;
180
182
netObject . isSpawned = true ;
181
183
if ( clientOwnerId != null )
@@ -192,11 +194,8 @@ internal static void OnSpawnObject(NetworkedObject netObject, int? clientOwnerId
192
194
writer . Write ( netObject . OwnerClientId ) ;
193
195
writer . Write ( netObject . SpawnablePrefabIndex ) ;
194
196
}
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 ( ) ) ;
200
199
}
201
200
}
202
201
}
0 commit comments