@@ -283,27 +283,21 @@ internal uint GetSourceGlobalObjectIdHash(uint networkPrefabHash)
283283 internal NetworkObject HandleNetworkPrefabSpawn ( uint networkPrefabAssetHash , ulong ownerClientId , Vector3 position , Quaternion rotation , byte [ ] instantiationData = null )
284284 {
285285 NetworkObject networkObjectInstance = null ;
286- var needsInstantiation = true ;
287286 if ( instantiationData != null )
288287 {
289288 if ( m_PrefabAssetToPrefabHandlerWithData . TryGetValue ( networkPrefabAssetHash , out var prefabInstanceHandler ) )
290289 {
291- needsInstantiation = false ;
292290 networkObjectInstance = prefabInstanceHandler . Instantiate ( ownerClientId , position , rotation , instantiationData ) ;
293291 }
294292 else
295293 {
296294 Debug . LogError ( $ "[InstantiationData] Failed instantiate with data: no compatible data handler found for object hash { networkPrefabAssetHash } . Instantiation data will be dropped.") ;
295+ return null ;
297296 }
298297 }
299-
300- // Fallback to default handler
301- if ( needsInstantiation )
298+ else if ( m_PrefabAssetToPrefabHandler . TryGetValue ( networkPrefabAssetHash , out var prefabInstanceHandler ) )
302299 {
303- if ( m_PrefabAssetToPrefabHandler . TryGetValue ( networkPrefabAssetHash , out var prefabInstanceHandler ) )
304- {
305- networkObjectInstance = prefabInstanceHandler . Instantiate ( ownerClientId , position , rotation ) ;
306- }
300+ networkObjectInstance = prefabInstanceHandler . Instantiate ( ownerClientId , position , rotation ) ;
307301 }
308302
309303 // Now we must make sure this alternate PrefabAsset spawned in place of the prefab asset with the networkPrefabAssetHash (GlobalObjectIdHash)
@@ -466,5 +460,10 @@ internal void Initialize(NetworkManager networkManager)
466460 {
467461 m_NetworkManager = networkManager ;
468462 }
463+
464+ internal void Shutdown ( )
465+ {
466+ m_PrefabInstanceToPrefabAsset . Clear ( ) ;
467+ }
469468 }
470469}
0 commit comments