Repository navigation
Fall back to scene.name for scenes not in Build Settings - #1083
Open
jimdroberts wants to merge 1 commit into
Open
jimdroberts wants to merge 1 commit into
jimdroberts wants to merge 1 commit into
Conversation
SceneLookupData(Scene) derived FullName from SceneUtility.GetScenePathByBuildIndex, which is empty for a scene not in Build Settings (buildIndex -1, e.g. Addressables). The server then told clients to load a scene named "". Fall back to scene.name when there is no build path; scenes in Build Settings are unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In 4.7.3, when the server loads a scene that is not in Build Settings, such as an Addressables scene, clients are told to load a scene with an empty name. The client-side load fails, so the client never joins the scene. Loading an already-loaded non-build scene for a connection fails the same way. Projects that load scenes through a custom
SceneProcessorBase, like the Addressables processor in the docs, are affected. We hit this in a project that loads every world scene through Addressables.Cause
Runtime/Managing/Scened/SceneLookupData.csL115-116 on main,SceneLookupData(Scene scene):A scene loaded from an AssetBundle or Addressables has
buildIndex == -1, andGetScenePathByBuildIndex(-1)returns an empty string.FullNameis therefore"".The server builds the lookup data it broadcasts from the loaded
Sceneobjects, inSceneManager.csL1462 (broadcastLookupData[i] = new(scene);) for newly loaded scenes and L1110 for scenes that are already loaded. The client receives a handle it cannot resolve locally and an empty name, and passes that empty name toBeginLoadAsync.The same constructor is also used by
SceneLoadData(Scene, ...)and byRemoveFromGlobalScenes(Scene)(L2321, called fromSceneManager_SceneUnloaded). WithFullNameempty, an unloaded non-build global scene is not removed from_globalScenes.This is a regression from 4.7.3R (dad140e). Earlier versions, including 4.6.x and 4.7.2, set
Name = scene.name.Fix
If there is no build path, use
scene.name. For scenes that are in Build Settings,Path.GetFileNameWithoutExtension(fullPath)andscene.nameare the same value, so nothing changes for them. Scenes outside Build Settings get their name back, as they did before 4.7.3.I checked the other places on main that use a build index or derive a scene name.
DefaultScene.GetSceneNameandSceneManager.IsGlobalScene/CheckForDuplicateGlobalSceneNameswork from user-supplied strings, not from build indices.ReserializeNetworkObjectsEditorand GameKit'sSceneDrawerare editor-only and enumerateEditorBuildSettings.scenes. This constructor is the only runtime place where a name is derived frombuildIndex.Evidence
Verified by reading.
SceneUtility.GetScenePathByBuildIndexis documented to return an empty string for an invalid index, andScene.buildIndexis documented as -1 for scenes loaded from an AssetBundle. The broadcast path above sends that value to clients unchanged. Compiled against Unity 6000.4 with no new errors or warnings.