Skip to content

Commit

Permalink
Pass buildOptions to the build with customParameters (#190)
Browse files Browse the repository at this point in the history
* Update Builder.cs

* update of buildOptions

buildOptions should be taken into account for build

* missed name
  • Loading branch information
marekvalenta authored Jan 5, 2021
1 parent 9f51040 commit c8202c0
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions action/default-build-script/Assets/Editor/Builder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,34 @@ public static void BuildProject()

// Gather values from project
var scenes = EditorBuildSettings.scenes.Where(scene => scene.enabled).Select(s => s.path).ToArray();

// Get all buildOptions from options
BuildOptions buildOptions = BuildOptions.None;
foreach (string buildOptionString in Enum.GetNames(typeof(BuildOptions))) {
if (options.ContainsKey(buildOptionString)) {
BuildOptions buildOptionEnum = (BuildOptions) Enum.Parse(typeof(BuildOptions), buildOptionString);
buildOptions |= buildOptionEnum;
}
}

// Define BuildPlayer Options
var buildOptions = new BuildPlayerOptions {
var buildPlayerOptions = new BuildPlayerOptions {
scenes = scenes,
locationPathName = options["customBuildPath"],
target = (BuildTarget) Enum.Parse(typeof(BuildTarget), options["buildTarget"]),
options = buildOptions
};

// Set version for this build
VersionApplicator.SetVersion(options["buildVersion"]);
VersionApplicator.SetAndroidVersionCode(options["androidVersionCode"]);

// Apply Android settings
if (buildOptions.target == BuildTarget.Android)
if (buildPlayerOptions.target == BuildTarget.Android)
AndroidSettings.Apply(options);

// Perform build
BuildReport buildReport = BuildPipeline.BuildPlayer(buildOptions);
BuildReport buildReport = BuildPipeline.BuildPlayer(buildPlayerOptions);

// Summary
BuildSummary summary = buildReport.summary;
Expand Down

0 comments on commit c8202c0

Please sign in to comment.