@@ -525,6 +525,16 @@ internal bool RemoveServerClientSceneHandle(int serverHandle, int clientHandle)
525525 /// </summary>
526526 internal Dictionary < int , uint > BuildIndexToHash = new Dictionary < int , uint > ( ) ;
527527
528+ /// <summary>
529+ /// Hash to external scene path lookup table
530+ /// </summary>
531+ internal Dictionary < uint , string > HashToExternalScenePath = new Dictionary < uint , string > ( ) ;
532+
533+ /// <summary>
534+ /// External scene name to hash lookup table
535+ /// </summary>
536+ internal Dictionary < string , uint > ExternalScenePathToHash = new Dictionary < string , uint > ( ) ;
537+
528538 /// <summary>
529539 /// The Condition: While a scene is asynchronously loaded in single loading scene mode, if any new NetworkObjects are spawned
530540 /// they need to be moved into the do not destroy temporary scene
@@ -706,6 +716,22 @@ internal void GenerateScenesInBuild()
706716 }
707717 }
708718
719+ /// <summary>
720+ /// Register scene from outside of build (e.g. from an Addressables group).
721+ /// </summary>
722+ /// <param name="scenePaths">The paths of the external scenes to register.</param>
723+ public void RegisterExternalScenes ( params string [ ] scenePaths )
724+ {
725+ HashToExternalScenePath . Clear ( ) ;
726+ ExternalScenePathToHash . Clear ( ) ;
727+ foreach ( var scenePath in scenePaths )
728+ {
729+ var hash = XXHash . Hash32 ( scenePath ) ;
730+ HashToExternalScenePath . Add ( hash , scenePath ) ;
731+ ExternalScenePathToHash . Add ( scenePath , hash ) ;
732+ }
733+ }
734+
709735 /// <summary>
710736 /// Gets the scene name from a hash value generated from the full scene path
711737 /// </summary>
@@ -727,7 +753,11 @@ internal string SceneNameFromHash(uint sceneHash)
727753 /// </summary>
728754 internal string ScenePathFromHash ( uint sceneHash )
729755 {
730- if ( HashToBuildIndex . ContainsKey ( sceneHash ) )
756+ if ( HashToExternalScenePath . TryGetValue ( sceneHash , out var externalScenePath ) )
757+ {
758+ return externalScenePath ;
759+ }
760+ else if ( HashToBuildIndex . ContainsKey ( sceneHash ) )
731761 {
732762 return SceneUtility . GetScenePathByBuildIndex ( HashToBuildIndex [ sceneHash ] ) ;
733763 }
@@ -743,6 +773,11 @@ internal string ScenePathFromHash(uint sceneHash)
743773 /// </summary>
744774 internal uint SceneHashFromNameOrPath ( string sceneNameOrPath )
745775 {
776+ if ( ExternalScenePathToHash . TryGetValue ( sceneNameOrPath , out var externalSceneHash ) )
777+ {
778+ return externalSceneHash ;
779+ }
780+
746781 var buildIndex = SceneUtility . GetBuildIndexByScenePath ( sceneNameOrPath ) ;
747782 if ( buildIndex >= 0 )
748783 {
0 commit comments