Skip to content

Commit e4cb1d1

Browse files
committed
fix
2 parents a8deca8 + 1d4ee06 commit e4cb1d1

File tree

27 files changed

+85080
-87766
lines changed

27 files changed

+85080
-87766
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"env": {
1515
"node": true,
1616
"es6": true,
17-
"jest/globals": true
17+
"jest/globals": true,
18+
"es2020": true
1819
},
1920
"rules": {
2021
// Error out for code formatting errors

.github/workflows/build-tests-mac.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ jobs:
2424
targetPlatform:
2525
- StandaloneOSX # Build a MacOS executable
2626
- iOS # Build an iOS executable
27+
include:
28+
# Additionally test enableGpu build for a standalone windows target
29+
- unityVersion: 6000.0.36f1
30+
targetPlatform: StandaloneOSX
31+
- unityVersion: 6000.0.36f1
32+
targetPlatform: StandaloneOSX
33+
buildProfile: 'Assets/Settings/Build Profiles/Sample macOS Build Profile.asset'
2734

2835
steps:
2936
###########################
@@ -65,6 +72,7 @@ jobs:
6572
projectPath: ${{ matrix.projectPath }}
6673
unityVersion: ${{ matrix.unityVersion }}
6774
targetPlatform: ${{ matrix.targetPlatform }}
75+
buildProfile: ${{ matrix.buildProfile }}
6876
customParameters: -profile SomeProfile -someBoolean -someValue exampleValue
6977
# We use dirty build because we are replacing the default project settings file above
7078
allowDirtyBuild: true
@@ -74,6 +82,6 @@ jobs:
7482
###########################
7583
- uses: actions/upload-artifact@v4
7684
with:
77-
name: Build ${{ matrix.targetPlatform }} on MacOS (${{ matrix.unityVersion }})
85+
name: Build ${{ matrix.targetPlatform }} on MacOS (${{ matrix.unityVersion }})${{ matrix.buildProfile && ' With Build Profile' || '' }}
7886
path: build
7987
retention-days: 14

.github/workflows/build-tests-windows.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@ jobs:
3434
unityVersion: 2023.2.2f1
3535
targetPlatform: StandaloneWindows64
3636
enableGpu: true
37-
37+
- unityVersion: 6000.0.36f1
38+
targetPlatform: StandaloneWindows64
39+
- unityVersion: 6000.0.36f1
40+
targetPlatform: StandaloneWindows64
41+
buildProfile: 'Assets/Settings/Build Profiles/Sample Windows Build Profile.asset'
42+
3843
steps:
3944
###########################
4045
# Checkout #
@@ -79,6 +84,7 @@ jobs:
7984
projectPath: ${{ matrix.projectPath }}
8085
unityVersion: ${{ matrix.unityVersion }}
8186
targetPlatform: ${{ matrix.targetPlatform }}
87+
buildProfile: ${{ matrix.buildProfile }}
8288
enableGpu: ${{ matrix.enableGpu }}
8389
customParameters: -profile SomeProfile -someBoolean -someValue exampleValue
8490
allowDirtyBuild: true
@@ -140,6 +146,6 @@ jobs:
140146
###########################
141147
- uses: actions/upload-artifact@v4
142148
with:
143-
name: Build ${{ matrix.targetPlatform }} on Windows (${{ matrix.unityVersion }})${{ matrix.enableGpu && ' With GPU' || '' }}
149+
name: Build ${{ matrix.targetPlatform }} on Windows (${{ matrix.unityVersion }})${{ matrix.enableGpu && ' With GPU' || '' }}${{ matrix.buildProfile && ' With Build Profile' || '' }}
144150
path: build
145151
retention-days: 14

dist/default-build-script/Assets/Editor/UnityBuilderAction/Builder.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,27 +56,36 @@ public static void BuildProject()
5656
// of either `UnityEditor.BuildPlayerOptions` or `UnityEditor.BuildPlayerWithProfileOptions`
5757
dynamic buildPlayerOptions;
5858

59-
if (options["customBuildProfile"] != "") {
59+
if (options.TryGetValue("activeBuildProfile", out var buildProfilePath)) {
60+
if (string.IsNullOrEmpty(buildProfilePath)) {
61+
throw new Exception("`-activeBuildProfile` is set but with an empty value; this shouldn't happen");
62+
}
6063

6164
#if UNITY_6000_0_OR_NEWER
6265
// Load build profile from Assets folder
63-
BuildProfile buildProfile = AssetDatabase.LoadAssetAtPath<BuildProfile>(options["customBuildProfile"]);
66+
var buildProfile = AssetDatabase.LoadAssetAtPath<BuildProfile>(buildProfilePath)
67+
?? throw new Exception("Build profile file not found at path: " + buildProfilePath);
6468

65-
// Set it as active
66-
BuildProfile.SetActiveBuildProfile(buildProfile);
69+
// no need to set active profile, as already set by `-activeBuildProfile` CLI argument
70+
// BuildProfile.SetActiveBuildProfile(buildProfile);
71+
Debug.Log($"build profile: {buildProfile.name}");
6772

6873
// Define BuildPlayerWithProfileOptions
6974
buildPlayerOptions = new BuildPlayerWithProfileOptions {
7075
buildProfile = buildProfile,
7176
locationPathName = options["customBuildPath"],
7277
options = buildOptions,
7378
};
74-
#else
79+
#else // UNITY_6000_0_OR_NEWER
7580
throw new Exception("Build profiles are not supported by this version of Unity (" + Application.unityVersion +")");
76-
#endif
81+
#endif // UNITY_6000_0_OR_NEWER
7782

7883
} else {
7984

85+
#if BUILD_PROFILE_LOADED
86+
throw new Exception("Build profile's define symbol present; shouldn't happen");
87+
#endif // BUILD_PROFILE_LOADED
88+
8089
// Gather values from project
8190
var scenes = EditorBuildSettings.scenes.Where(scene => scene.enabled).Select(s => s.path).ToArray();
8291

dist/default-build-script/Assets/Editor/UnityBuilderAction/Input/AndroidSettings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ public static void Apply(Dictionary<string, string> options)
115115
}
116116
}
117117

118+
#if UNITY_6000_0_OR_NEWER
118119
private static void SetDebugSymbols(string enumValueName)
119120
{
120121
// UnityEditor.Android.UserBuildSettings and Unity.Android.Types.DebugSymbolLevel are part of the Unity Android module.
@@ -144,5 +145,6 @@ private static void SetDebugSymbols(string enumValueName)
144145
}
145146
levelProp.SetValue(null, enumValue);
146147
}
148+
#endif
147149
}
148150
}

dist/default-build-script/Assets/Editor/UnityBuilderAction/Input/ArgumentsParser.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@ public static Dictionary<string, string> GetValidatedOptions()
2121
EditorApplication.Exit(110);
2222
}
2323

24+
#if UNITY_6000_0_OR_NEWER
25+
var buildProfileSupport = true;
26+
#else
27+
var buildProfileSupport = false;
28+
#endif // UNITY_6000_0_OR_NEWER
29+
30+
string buildProfile;
31+
if (buildProfileSupport && validatedOptions.TryGetValue("activeBuildProfile", out buildProfile)) {
32+
if (validatedOptions.ContainsKey("buildTarget")) {
33+
Console.WriteLine("Extra argument -buildTarget");
34+
EditorApplication.Exit(122);
35+
}
36+
} else {
2437
string buildTarget;
2538
if (!validatedOptions.TryGetValue("buildTarget", out buildTarget)) {
2639
Console.WriteLine("Missing argument -buildTarget");
@@ -31,6 +44,7 @@ public static Dictionary<string, string> GetValidatedOptions()
3144
Console.WriteLine(buildTarget + " is not a defined " + typeof(BuildTarget).Name);
3245
EditorApplication.Exit(121);
3346
}
47+
}
3448

3549
string customBuildPath;
3650
if (!validatedOptions.TryGetValue("customBuildPath", out customBuildPath)) {

0 commit comments

Comments
 (0)