- Home /
Question by
cowlinator · Mar 18, 2013 at 06:37 PM ·
scenesbuild settings
Does EditorBuildSettings.scenes use just the checkboxed scenes?
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?
Comment
Best Answer
Answer by cowlinator · Mar 18, 2013 at 07:12 PM
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);
}
}
Answer by roberto_sc · Jan 15, 2014 at 04:39 AM
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();
Works as expected, make sure you are using Linq
at the top of your file.
using System.Linq;
...
static string[] EnabledScenes ()
{
return (
from scene in EditorBuildSettings.scenes
where scene.enabled
select scene.path
).ToArray ();
}