Skip to content

Commit b50706f

Browse files
fix
Prevent multiple scenes from being added to the scenes in build list.
1 parent ba35384 commit b50706f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

com.unity.netcode.gameobjects/Editor/NetworkManagerHelper.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,15 @@ private static void ScenesInBuildActiveSceneCheck()
104104
$"to synchronize to this scene unless it is added to the scenes in build list.\n\nWould you like to add it now?",
105105
"Yes", "No - Continue"))
106106
{
107-
scenesList.Add(new EditorBuildSettingsScene(activeScene.path, true));
108-
EditorBuildSettings.scenes = scenesList.ToArray();
107+
// Double double check that the EditorBuildSettings.scenes has not changed already before adding
108+
// this scene to the array (Parrel Sync issue)
109+
scenesList = EditorBuildSettings.scenes.ToList();
110+
isSceneInBuildSettings = scenesList.Count((c) => c.path == activeScene.path) == 1;
111+
if (!isSceneInBuildSettings)
112+
{
113+
scenesList.Add(new EditorBuildSettingsScene(activeScene.path, true));
114+
EditorBuildSettings.scenes = scenesList.ToArray();
115+
}
109116
}
110117
}
111118
}

0 commit comments

Comments
 (0)