I'm using a C# script to call BuildPipeline to make standalone and web player versions of our simulation. I couldn't find a way to access the list of scenes to build under the Build Settings UI. Now I see in Library there's a file called BuildSettings.asset. Can I use the AssetBundle API to load this and read the build settings automatically from my project so as not to hardcode the list of scenes into my project file? If not, where can I access the list of scenes that are displayed in the Build Settings UI?
Maybe what you are seeking is the editorbuildsettings.scenes ? I don't know if you can add new scenes to it, but It provides the information you want to have (path to the scene and if it is enabled in your building scene settings).
hope that was helpful.
regards
Edit: tried myself to add new scenes to the scenes and it works. So if you have all your gamescenes in one directory you can read all filenames from this directory and add them to the editorbuildsettings.scenes automatically.
private static string FillLevels()
{
return (from scene in EditorBuildSettings.scenes where scene.enabled select scene.path).ToArray();
}
You can do something like the following in order to modify the set of scenes in the ‘Build Settings’ menu via an editor script:
var original = EditorBuildSettings.scenes;
var newSettings = new EditorBuildSettingsScene[original.Length + 1];
System.Array.Copy(original, newSettings, original.Length);
var sceneToAdd = new EditorBuildSettingsScene("Assets/Path/To/Scene/sceneName.unity", false);
newSettings[newSettings.Length - 1] = sceneToAdd;
EditorBuildSettings.scenes = newSettings;
That will add a new scene to the list of scenes. You can remove scenes or modify the ‘enabled’ property by accessing the same EditorBuildSettings.scenes array.
While you cannot change the selected scenes displayed in the build settings window from a script, you can make custom builds using BuildPipeline.BuildPlayer, which lets you pass the scenes to build as a parameter.
a hacky way I found to do it is just read the EditorBuildSettings.asset file in as a string and scan for ".unity". The scene paths are stored in there, but so is the build name so make sure the ".unity" isn't followed by "3d"
I have the same kind of problem, I would like to set by script the Build Settings. In my case I want to set the plateform (iOS) and then the size of the game tab inside unity (iPhone Wide (480x320)).
I have created a script to setup a project folder with the available commands, but I would like to set those properties as well because it's very annoying to change them back each time you create a new branch.
Thanks.