- Home /
Modify Scenes in EditorBuildSettings.scenes via script
Hi, I have various projects sharing the same project folder (because they are basically skins using the same base code) , I'm managing this via anEditor Script that basically opens the correct game scene and setups PlayerSettings
with the correct settings but I would like to also modify the scene paths used in the buildSettings using EditorBuildSettings.scenes
, but this code is not working despite Im having no errors:
static void SetupBuildScenes(string scene)
{
for (int i = 0; i < EditorBuildSettings.scenes.Length; i++)
{
if (EditorBuildSettings.scenes[i].path != "Assets/Scenes/LoadingScene.unity")
{
Debug.Log("Scene found, setting game scene for game: " + scene);
EditorBuildSettings.scenes[i].path = "Assets/Scenes/" + scene + "/" + scene.Replace(" ","") + ".unity";
}
}
}
Any tips for this?
Edit: I found this question and it gave me the solution to mine, I updated the code to this and it worked!
static void SetupBuildScenes(string scene)
{
EditorBuildSettingsScene[] scenes = EditorBuildSettings.scenes;
foreach (EditorBuildSettingsScene gameScene in scenes)
{
if (gameScene.path != "Assets/Scenes/LoadingScene.unity")
{
Debug.Log("Scene found, setting game scene for game: " + scene);
gameScene.path = "Assets/Scenes/" + scene + "/" + scene.Replace(" ","") + ".unity";
}
}
EditorBuildSettings.scenes = scenes;
}
P.S: I hope this post is understandable english is not my mother tongue.
Comment