Modify "Builds Settings/Scenes to Build" in Script

We have a custom publishing script that uses UnityEditor.BuildPipeline, however when testing in the editor Application.LoadLevel() fails because we don't use the human-driven build settings menu. I'd like to write an editor script which automatically syncs those settings with our build script to avoid this, but there aren't any methods in the UnityEditor API for doing this... or am I missing something?

If I understand you correctly you want to read the values that are displayed in the Build Settings dialog. I too had this question before and there is no apparent way to read from the build settings asset file. So you're not missing anything, its simply not there.

I know this is an old Q&A, but there is now an API for that, see Unity - Scripting API: EditorUserBuildSettings