-
-
Notifications
You must be signed in to change notification settings - Fork 122
Document new buildProfile
config option
#498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,9 @@ | |
using System.Linq; | ||
using UnityEditor; | ||
using UnityEditor.Build.Reporting; | ||
#if UNITY_6000_0_OR_NEWER | ||
using UnityEditor.Build.Profile; | ||
#endif | ||
|
||
namespace UnityBuilderAction | ||
{ | ||
|
@@ -89,6 +92,31 @@ public static void Build() | |
Build(buildTarget, buildSubtarget, options["customBuildPath"]); | ||
} | ||
|
||
#if UNITY_6000_0_OR_NEWER | ||
public static void BuildWithProfile() | ||
{ | ||
// Gather values from args | ||
Dictionary<string, string> options = GetValidatedOptions(); | ||
|
||
// Load build profile from Assets folder | ||
BuildProfile buildProfile = AssetDatabase.LoadAssetAtPath<BuildProfile>(options["customBuildProfile"]); | ||
|
||
// Set it as active | ||
BuildProfile.SetActiveBuildProfile(buildProfile); | ||
|
||
// Define BuildPlayerWithProfileOptions | ||
var buildPlayerWithProfileOptions = new BuildPlayerWithProfileOptions { | ||
buildProfile = buildProfile, | ||
locationPathName = options["customBuildPath"], | ||
options = buildOptions, | ||
}; | ||
|
||
BuildSummary buildSummary = BuildPipeline.BuildPlayer(buildPlayerWithProfileOptions).summary; | ||
ReportSummary(buildSummary); | ||
ExitWithResult(buildSummary.result); | ||
} | ||
#endif | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Update GetValidatedOptions for build profile support. The GetValidatedOptions method should be updated to validate the customBuildProfile option when using Unity 6.0.0 or newer. Apply this diff to update the method: private static Dictionary<string, string> GetValidatedOptions()
{
ParseCommandLineArguments(out Dictionary<string, string> validatedOptions);
+#if UNITY_6000_0_OR_NEWER
+ // Validate customBuildProfile when using BuildWithProfile
+ if (validatedOptions.TryGetValue("buildWithProfile", out string useProfile) &&
+ useProfile.ToLower() == "true" &&
+ !validatedOptions.TryGetValue("customBuildProfile", out string _))
+ {
+ Console.WriteLine("Missing argument -customBuildProfile when buildWithProfile is true");
+ EditorApplication.Exit(140);
+ }
+#endif
|
||
private static Dictionary<string, string> GetValidatedOptions() | ||
{ | ||
ParseCommandLineArguments(out Dictionary<string, string> validatedOptions); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.