- Home /
Proper usage of EditorUserBuildSettings and BuildOptions
Hey all,
I'm trying to automate our build process here a little, and I'm not sure I truly understand the proper usage of EditorUserBuildSettings and BuildOptions. Here is a very basic implementation of what I am trying to achieve, hopefully it is enough to get my point across:
Note: it should be implied that for this example I am functioning under iOS build settings.
EditorUserBuildSettings.appendProject = true; //if we're building iOS, insure we're always appending and not building fresh every time.
BuildOptions customBuildOptions = EditorUserBuildSettings.architectureFlags;
BuildTarget customBuildTarget=EditorUserBuildSettings.activeBuildTarget;
string savepath = EditorUtility.SaveFolderPanel("Build "+customBuildTarget, EditorUserBuildSettings.GetBuildLocation(customBuildTarget), "");
if(savepath.Length != 0)
{
string dir=System.IO.Path.GetDirectoryName(savepath); //get build directory
string[] scenes=new string[EditorBuildSettings.scenes.Length];
for(int i=0;i < EditorBuildSettings.scenes.Length; ++i)
{
scenes[i]=EditorBuildSettings.scenes[i].path.ToString();
}
//////
// Do some preprocess stuff right here
//////
EditorUserBuildSettings.SetBuildLocation(customBuildTarget,dir); //store new location for this type of build
BuildPipeline.BuildPlayer(scenes, savepath, BuildTarget.iPhone, customBuildOptions);
//////
// Do some posprocess stuff right here
//////
}
My expectations are that the XCode project will be appended - however it does not seem like that is the case, it writes a fresh project to my specified directory every time I run the script.
I tried scouring the docs but, as with most of the Editor API, documentation is really non-existant and lacking any form of example.
Thanks in advance
==
Answer by Matt(Trip)Maker · Jun 28, 2013 at 07:34 PM
for this particular script, I think you could add this line up top:
EditorUserBuildSettings.architectureFlags = EditorUserBuildSettings.architectureFlags | BuildOptions.AcceptExternalModificationsToPlayer;
Your answer
![](https://koobas.hobune.stream/wayback/20220613071403im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Editor Script: Build for multiple platforms at once. 1 Answer
Unity PreBuild Step for Custom Plugins 0 Answers
Cancel build in PostProcessScene? 0 Answers
How do I release editor memory? 2 Answers