@@ -1753,33 +1753,37 @@ internal void GetObjectDistribution(ref Dictionary<uint, Dictionary<ulong, List<
17531753 continue ;
17541754 }
17551755 }
1756+ // We have to check if it is an in-scene placed NetworkObject and if it is get the source prefab asset GlobalObjectIdHash value of the in-scene placed instance
1757+ // since all in-scene placed instances use unique GlobalObjectIdHash values.
1758+ var globalOjectIdHash = networkObject . IsSceneObject . HasValue && networkObject . IsSceneObject . Value ? networkObject . InScenePlacedSourceGlobalObjectIdHash : networkObject . GlobalObjectIdHash ;
17561759
1757- if ( ! objectTypeCount . ContainsKey ( networkObject . GlobalObjectIdHash ) )
1760+ if ( ! objectTypeCount . ContainsKey ( globalOjectIdHash ) )
17581761 {
1759- objectTypeCount . Add ( networkObject . GlobalObjectIdHash , 0 ) ;
1762+ objectTypeCount . Add ( globalOjectIdHash , 0 ) ;
17601763 }
1761- objectTypeCount [ networkObject . GlobalObjectIdHash ] += 1 ;
1764+ objectTypeCount [ globalOjectIdHash ] += 1 ;
17621765
17631766 // DANGO-TODO-MVP: Remove this once the service handles object distribution
17641767 if ( onlyIncludeOwnedObjects && ! networkObject . IsOwner )
17651768 {
17661769 continue ;
17671770 }
17681771
1772+
17691773 // Divide up by prefab type (GlobalObjectIdHash) to get a better distribution of object types
1770- if ( ! objectByTypeAndOwner . ContainsKey ( networkObject . GlobalObjectIdHash ) )
1774+ if ( ! objectByTypeAndOwner . ContainsKey ( globalOjectIdHash ) )
17711775 {
1772- objectByTypeAndOwner . Add ( networkObject . GlobalObjectIdHash , new Dictionary < ulong , List < NetworkObject > > ( ) ) ;
1776+ objectByTypeAndOwner . Add ( globalOjectIdHash , new Dictionary < ulong , List < NetworkObject > > ( ) ) ;
17731777 }
17741778
17751779 // Sub-divide each type by owner
1776- if ( ! objectByTypeAndOwner [ networkObject . GlobalObjectIdHash ] . ContainsKey ( networkObject . OwnerClientId ) )
1780+ if ( ! objectByTypeAndOwner [ globalOjectIdHash ] . ContainsKey ( networkObject . OwnerClientId ) )
17771781 {
1778- objectByTypeAndOwner [ networkObject . GlobalObjectIdHash ] . Add ( networkObject . OwnerClientId , new List < NetworkObject > ( ) ) ;
1782+ objectByTypeAndOwner [ globalOjectIdHash ] . Add ( networkObject . OwnerClientId , new List < NetworkObject > ( ) ) ;
17791783 }
17801784
17811785 // Add to the client's spawned object list
1782- objectByTypeAndOwner [ networkObject . GlobalObjectIdHash ] [ networkObject . OwnerClientId ] . Add ( networkObject ) ;
1786+ objectByTypeAndOwner [ globalOjectIdHash ] [ networkObject . OwnerClientId ] . Add ( networkObject ) ;
17831787 }
17841788 }
17851789 }
@@ -1864,7 +1868,7 @@ internal void DistributeNetworkObjects(ulong clientId)
18641868 if ( ( i % offsetCount ) == 0 )
18651869 {
18661870 ChangeOwnership ( ownerList . Value [ i ] , clientId , true ) ;
1867- if ( EnableDistributeLogging )
1871+ // if (EnableDistributeLogging)
18681872 {
18691873 Debug . Log ( $ "[Client-{ ownerList . Key } ][NetworkObjectId-{ ownerList . Value [ i ] . NetworkObjectId } Distributed to Client-{ clientId } ") ;
18701874 }
0 commit comments