-
-
Save ArthurD/c2ca0d77166e55dc083d6f097426045b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class RunBuild { | |
private readonly static string[] Scenes = new string[] { | |
"Assets/Scenes/GameLoader.unity", | |
"Assets/Scenes/Main Menu.unity", | |
"Assets/Scenes/OpenWorld.unity", | |
"Assets/Scenes/Gameplay.unity" | |
}; | |
public static void MakeBuild_CLI() { | |
var args = System.Environment.GetCommandLineArgs(); | |
int optionsMask = -1; | |
DateTime dt = new DateTime(); | |
BuildTarget buildTarget = BuildTarget.NoTarget; | |
Branch branch = Branch.Default; | |
string tgt = string.Empty; | |
for(int i=0; i<args.Length; i++) { | |
if(args[i] == "-options") | |
optionsMask = int.Parse(args[i + 1]); | |
if (args[i] == "-buildDate") | |
dt = new DateTime(long.Parse(args[i + 1])); | |
if (args[i] == "-tgt") { | |
tgt = args[i + 1]; | |
if (tgt == "WIN") { | |
buildTarget = BuildTarget.StandaloneWindows64; | |
} else if(tgt == "MAC") { | |
buildTarget = BuildTarget.StandaloneOSX; | |
} else if(tgt == "MAS") { | |
buildTarget = BuildTarget.StandaloneOSX; | |
} | |
} | |
if (args[i] == "-branch") | |
branch = (Branch) System.Enum.Parse(typeof(Branch), args[i + 1]); | |
} | |
MakeOneBuild(dt, optionsMask, branch, buildTarget, tgt == "MAS"); | |
} | |
private static int GetSettingsIndexForAddressables() { | |
for (int i = 0; i < AddressableAssetSettingsDefaultObject.Settings.DataBuilders.Count; i++) { | |
BuildScriptInherited builder = AddressableAssetSettingsDefaultObject.Settings.DataBuilders[i] as BuildScriptInherited; | |
if (builder != null && builder.Name == "Packed Variations") { | |
return i; | |
} | |
} | |
Debug.LogError("Could not find Packed Variations builder"); | |
return -1; | |
} | |
private static void MakeOneBuild(DateTime buildDate, int optionsMask, Branch branch, BuildTarget target, bool isMacAppStore) { | |
// Disable Unity Splash Screen via code (in case it got committed the opposite way) | |
PlayerSettings.SplashScreen.showUnityLogo = false; | |
// Build Date, Scripting Defines | |
PlayerSettings.bundleVersion = BuildDate.ToString(buildDate); | |
PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, ScriptingDefines(optionsMask, branch, isMacAppStore)); | |
// If !DryRun -- DO IT! | |
if (!BuildMakerWindow.isProperty(BuildMakerWindow.BProp.DRY_RUN, optionsMask)) { | |
// Handle Addressables, which are actually Asset Bundles. | |
AddressableAssetSettingsDefaultObject.Settings.ActivePlayerDataBuilderIndex = GetSettingsIndexForAddressables(); | |
AddressableAssetSettings.BuildPlayerContent(); | |
// Build it | |
BuildPipeline.BuildPlayer(Scenes, FullPathForSingleBuild(buildDate, branch, target, isMacAppStore), target, GetBuildOptions(optionsMask)); | |
// Copy the Steam Deploy template files over -- on a *PER BRANCH* basis! | |
if (!isMacAppStore) | |
BuildAppDeployFromTemplate(buildDate, branch); | |
// Build Date | |
BuildDate.SetBuildInformation(new BuildTimeInfo { BuildDateTime = buildDate }, DirForBuilds(buildDate, branch)); | |
} | |
} | |
private static string ScriptingDefines(int mask, Branch branch, bool isMacAppStore) { | |
// Handle Options | |
string scriptingDefines = DefineForBranch(branch); | |
if (BuildMakerWindow.isProperty(BuildMakerWindow.BProp.SteamCheck, mask) == false || isMacAppStore) | |
scriptingDefines += ";SKIP_STEAM_CHECK"; | |
if (BuildMakerWindow.isProperty(BuildMakerWindow.BProp.Cheats, mask)) | |
scriptingDefines += ";CHEATS"; | |
scriptingDefines += ";PUBLIC_RELEASE"; | |
scriptingDefines += ";GPU_INSTANCER"; | |
if (isMacAppStore) | |
scriptingDefines += ";MAC_APP_STORE"; | |
return scriptingDefines; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment