There is nill documentation on EditorBuildSettings.scenes. Does it return an array of all the scenes in the build settings window, or just the ones that have the checkboxes?
If it returns all the scenes, is there a way to test if they are checkboxed true?
2 Answers
2
I’ve figured it out. It returns an array of all the scenes in the build settings window.
You can get just the enabled scenes like so:
List<EditorBuildSettingsScene> scenes = new List<EditorBuildSettingsScene>(EditorBuildSettings.scenes);
List<string> enabledScenes = new List<string>();
foreach (EditorBuildSettingsScene scene in scenes)
{
if (scene.enabled)
{
enabledScenes.Add(scene.path);
}
}
In case you want to use Linq:
string[] scenes = (from scene in EditorBuildSettings.scenes
where scene.enabled select scene.path).ToArray();
Or another way in Linq using method syntax: var scenes = EditorBuildSettings.scenes.Where(scene => scene.enabled).Select(scene => scene.path).ToArray();
– samizzoWorks as expected, make sure you are using
– GabLeRouxLinqat the top of your file. using System.Linq; ... static string[] EnabledScenes () { return ( from scene in EditorBuildSettings.scenes where scene.enabled select scene.path ).ToArray (); }