Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
4
Question by Ben 2 · Jan 22, 2010 at 04:46 PM · buildassetbundleassetworkflow

Accessing BuildSettings from BuildSettings.asset

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?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

6 Replies

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by pahe · Mar 21, 2011 at 02:11 PM

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
6

Answer by Neodrop · Jan 25, 2012 at 03:05 PM

 private static string[] FillLevels()
 {
     return (from scene in EditorBuildSettings.scenes where scene.enabled select scene.path).ToArray();
 }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
3

Answer by AntonStruyk · Oct 14, 2011 at 02:58 PM

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by jonas-echterhoff · Jan 23, 2010 at 02:54 PM

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.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Ben 2 · Jan 24, 2010 at 04:49 AM 0
Share

Right but I don't want to have to specify the names of the scenes, I want to access the list of scenes to compile from wherever they are stored when they are set by the user in Unity. Then if the user were to edit the list of scenes in the Build Settings UI, my continuous integration script would automatically include the new scene. As it is now, the scene list is hardcoded in the build script and so has to be updated if the build settings are changed.

avatar image jonas-echterhoff ♦♦ · Jan 24, 2010 at 02:19 PM 0
Share

I don't think it is possible to get this information from a script. $$anonymous$$y advise is to implement a custom build solution using BuildPipeline.BuildPlayer, and implement your own scene list management.

avatar image
1

Answer by Russ Gresh · Jul 30, 2010 at 06:11 PM

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"

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Ben 2 · Aug 02, 2010 at 05:56 PM 0
Share

Yeah, if doing this from a command line script in OS X or similar OS you can use 'strings -a BuildSettings.asset | grep unity' and you'll see the list there. Its an ok answer but as you said, its a hack.

avatar image Gungnir · May 26, 2011 at 09:46 AM 0
Share

Hi, I tried doing this from inside Unity using a streamreader and the www class. Both methods fail and return an empty file. Any ideas?

Note: When i open the file in notepad the file has text in it (and symbols etc) but when i open it inside monodevelop it appears empty.

editorbuildsettings.scenes is useless for what i want to do because it only works inside an editor script >.<. $$anonymous$$assive fail unity3d.

  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

Where are the built scripts stored in a build? 1 Answer

AssetBundles - depend on asset already included in executable 0 Answers

Can AssetDatabase.LoadAllAssetsAtPath Load All Assets Recursively? 2 Answers

Distribute terrain in zones 3 Answers

How much is downloaded from addressable groups? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges