private static void PerformPostBuild( BuildReleaseType releaseType, BuildPlatform platform, BuildArchitecture architecture, BuildDistribution distribution, DateTime buildTime, ref BuildOptions options, string configKey, string buildPath) { BuildAction[] buildActions = BuildSettings.postBuildActions.buildActions; if (buildActions != null) { for (int i = 0; i < buildActions.Length; i++) { BuildAction action = buildActions[i]; // Check if execute method has been overriden. MethodInfo m = action.GetType().GetMethod("PerBuildExecute"); if (m.GetBaseDefinition().DeclaringType != m.DeclaringType && action.actionType == BuildAction.ActionType.PerPlatform) { // Check build filter and execute if true. if (action.filter == null || action.filter.Evaluate(releaseType, platform, architecture, distribution, configKey) && action.actionEnabled) { BuildNotificationList.instance.AddNotification(new BuildNotification( BuildNotification.Category.Notification, string.Format("Performing Post-Build Action ({0}/{1}).", i + 1, buildActions.Length), string.Format("{0}: {1}", action.actionName, configKey), true, null)); action.PerBuildExecute(releaseType, platform, architecture, distribution, buildTime, ref options, configKey, buildPath); } else { BuildNotificationList.instance.AddNotification(new BuildNotification( BuildNotification.Category.Notification, string.Format("Skipping Post-Build Action ({0}/{1}).", i + 1, buildActions.Length), string.Format("{0}: {1}", action.actionName, configKey), true, null)); } } } } }
public override void Init() { platformName = _name; binaryNameFormat = _binaryNameFormat; dataDirNameFormat = _dataDirNameFormat; targetGroup = _targetGroup; if (architectures == null || architectures.Length == 0) { architectures = new BuildArchitecture[] { new BuildArchitecture(BuildTarget.Android, "Android", true) }; } if (variants == null || variants.Length == 0) { variants = new BuildVariant[] { new BuildVariant("Device Type", new string[] { "FAT", "ARMv7", "x86" }, 0), new BuildVariant("Texture Compression", new string[] { "ETC", "ETC2", "ASTC", "DXT", "PVRTC", "ATC", "Generic" }, 0), new BuildVariant("Build System", new string[] { "Internal", "Gradle", "ADT (Legacy)" }, 0) }; } }
public override void Init() { platformName = _name; dataDirNameFormat = _dataDirNameFormat; targetGroup = _targetGroup; if (architectures == null || architectures.Length == 0) { architectures = new BuildArchitecture[] { new BuildArchitecture(BuildTarget.WSAPlayer, "Universal Windows Platform", true, _binaryNameFormat) }; } if (variants == null || variants.Length == 0) { variants = new BuildVariant[] { new BuildVariant("Target Device", new string[] { "AnyDevice", "PC", "Mobile", "HoloLens" }, 0), new BuildVariant("Architecture", new string[] { "x64", "x86", "ARM" }, 0), new BuildVariant("Build Type", new string[] { "XAML", "D3D" }, 0) // new BuildVariant("Build Configuration", new string[] { "Release", "Debug", "Master"}, 0), }; } }
public static string GenerateDefaultDefines(BuildReleaseType releaseType, BuildPlatform buildPlatform, BuildArchitecture arch, BuildDistribution dist) { List <string> defines = new List <string>(); if (releaseType != null) { defines.Add("BUILD_TYPE_" + SanitizeCodeString(releaseType.typeName.ToUpper().Replace(" ", ""))); } if (buildPlatform != null) { defines.Add("BUILD_PLATFORM_" + SanitizeCodeString(buildPlatform.platformName.ToUpper().Replace(" ", ""))); } if (arch != null) { defines.Add("BUILD_ARCH_" + SanitizeCodeString(arch.name.ToUpper().Replace(" ", ""))); } if (dist != null) { defines.Add("BUILD_DIST_" + SanitizeCodeString(dist.distributionName.ToUpper().Replace(" ", ""))); } if (releaseType != null && !string.IsNullOrEmpty(releaseType.customDefines)) { string[] customDefines = releaseType.customDefines.Split(';', ','); for (int i = 0; i < customDefines.Length; i++) { defines.Add(SanitizeCodeString(customDefines[i]).ToUpper()); } } return(string.Join(";", defines.ToArray())); }
public override void PerBuildExecute(BuildReleaseType releaseType, BuildPlatform platform, BuildArchitecture architecture, BuildDistribution distribution, System.DateTime buildTime, ref BuildOptions options, string configKey, string buildPath) { StringBuilder defines = new StringBuilder(BuildProject.GenerateDefaultDefines(releaseType, platform, architecture, distribution)); if (!string.IsNullOrEmpty(removeDefines)) { string resolvedRemove = BuildProject.ResolvePath(removeDefines, releaseType, platform, architecture, distribution, buildTime); string[] splitRemove = resolvedRemove.Split(';'); for (int i = 0; i < splitRemove.Length; i++) { defines.Replace(splitRemove[i] + ";", ""); defines.Replace(splitRemove[i], ""); } } if (!string.IsNullOrEmpty(addDefines)) { string resolvedAdd = BuildProject.ResolvePath(addDefines, releaseType, platform, architecture, distribution, buildTime); if (defines.Length > 0) { defines.Append(";" + resolvedAdd); } else { defines.Append(resolvedAdd); } } PlayerSettings.SetScriptingDefineSymbolsForGroup(platform.targetGroup, defines.ToString()); }
public override void PerBuildExecute(BuildReleaseType releaseType, BuildPlatform platform, BuildArchitecture architecture, BuildDistribution distribution, System.DateTime buildTime, ref BuildOptions options, string configKey, string buildPath) { string resolvedInputPath = BuildProject.ResolvePath(inputPath.Replace("$BUILDPATH", buildPath), releaseType, platform, architecture, distribution, buildTime); string resolvedOutputPath = BuildProject.ResolvePath(outputPath.Replace("$BUILDPATH", buildPath), releaseType, platform, architecture, distribution, buildTime); switch (operation) { case Operation.Copy: Copy(resolvedInputPath, resolvedOutputPath); break; case Operation.Move: Move(resolvedInputPath, resolvedOutputPath); break; case Operation.Delete: Delete(resolvedInputPath); break; } AssetDatabase.Refresh(); }
public override void PerBuildExecute(BuildReleaseType releaseType, BuildPlatform platform, BuildArchitecture architecture, BuildDistribution distribution, System.DateTime buildTime, ref BuildOptions options, string configKey, string buildPath) { // Verify that butler executable exists. if (!File.Exists(pathToButlerExe)) { UnityEngine.Debug.LogError("Couldn't find butler.exe file at path \"" + pathToButlerExe + "\", please check provided path"); return; } buildPath = Path.GetFullPath(buildPath); // Generate build args for the form: butler push {optional args} {build path} {itch username}/{itch game}:{channel} StringBuilder scriptArguments = new StringBuilder("push "); switch (architecture.target) { #if UNITY_2017_3_OR_NEWER case BuildTarget.StandaloneOSX: #else case BuildTarget.StandaloneOSXIntel: case BuildTarget.StandaloneOSXIntel64: case BuildTarget.StandaloneOSXUniversal: #endif case BuildTarget.StandaloneLinux: case BuildTarget.StandaloneLinux64: case BuildTarget.StandaloneLinuxUniversal: // Fix exe permissions for Linux/OSX. scriptArguments.Append("--fix-permissions "); break; } if (useGeneratedBuildVersion) { // Append generated versions string. scriptArguments.Append(string.Format("--userversion \"{0}\" ", BuildSettings.productParameters.lastGeneratedVersion)); } scriptArguments.Append("\"" + buildPath + "\"" + " " + nameOfItchUser + "/" + nameOfItchGame + ":"); if (!string.IsNullOrEmpty(itchChannelOverride)) { scriptArguments.Append(itchChannelOverride); } else { string itchChannel = GetChannelName(architecture.target); if (string.IsNullOrEmpty(itchChannel)) { UnityEngine.Debug.LogWarning("UploadItch: The current BuildTarget doesn't appear to be a standard Itch.IO build target."); } scriptArguments.Append(itchChannel); } // UnityEngine.Debug.Log("Would have run itch uploader with following command line: \"" + pathToButlerExe + " " + scriptArguments + "\""); RunScript(pathToButlerExe, scriptArguments.ToString()); }
public bool ParseKeychain(string keychain, out BuildReleaseType releaseType, out BuildPlatform platform, out BuildArchitecture architecture, out BuildDistribution distribution) { bool success = false; string[] keys = keychain.Split('/'); int keyCount = keys.Length; int targetKey = 0; releaseType = null; platform = null; architecture = null; distribution = null; // Parse release type. if (keyCount > targetKey) { for (int i = 0; i < BuildSettings.releaseTypeList.releaseTypes.Length; i++) { BuildReleaseType rt = BuildSettings.releaseTypeList.releaseTypes[i]; if (keys[targetKey] == rt.typeName) { releaseType = rt; break; } } } if (releaseType == null) { return(false); } // Parse platform. if (keyCount > ++targetKey) { // Scan ahead and try to parse a variant key. string variantKey = ""; if (keys[targetKey + 1].Contains("(")) { int startIndex = keys[targetKey + 1].IndexOf('('); int endIndex = keys[targetKey + 1].IndexOf(')'); variantKey = keys[targetKey + 1].Substring(startIndex + 1, endIndex - startIndex - 1); keys[targetKey + 1] = keys[targetKey + 1].Remove(startIndex).Trim(); } for (int i = 0; i < BuildSettings.platformList.platforms.Count; i++) { BuildPlatform p = BuildSettings.platformList.platforms[i]; if (keys[targetKey] == p.platformName && p.variantKey == variantKey) { platform = p; break; } } } if (platform == null) { return(false); } // Parse architecture. if (platform.architectures.Length == 1) { // Only one architecture, so it won't even appear in dictionary. Just get it directly. ++targetKey; architecture = platform.architectures[0]; success = true; } else if (keyCount > ++targetKey) { for (int i = 0; i < platform.architectures.Length; i++) { BuildArchitecture arch = platform.architectures[i]; if (keys[targetKey] == arch.name) { architecture = arch; success = true; break; } } } if (architecture == null) { return(false); } // TODO: Parse variants. // Parse distribution. if (keyCount > ++targetKey) { success = false; for (int i = 0; i < platform.distributionList.distributions.Length; i++) { BuildDistribution dist = platform.distributionList.distributions[i]; if (keys[targetKey] == dist.distributionName) { distribution = dist; success = true; break; } } } return(success); }
public override void PerBuildExecute(BuildReleaseType releaseType, BuildPlatform platform, BuildArchitecture architecture, BuildDistribution distribution, System.DateTime buildTime, ref BuildOptions options, string configKey, string buildPath) { string resolvedScriptPath = BuildProject.ResolvePath(scriptPath, releaseType, platform, architecture, distribution, buildTime); string resolvedScriptArgs = BuildProject.ResolvePath(scriptArguments, releaseType, platform, architecture, distribution, buildTime); RunScript(resolvedScriptPath, resolvedScriptArgs); }
public static string ResolvePath(string prototype, BuildReleaseType releaseType, BuildPlatform buildPlatform, BuildArchitecture arch, BuildDistribution dist, DateTime buildTime) { StringBuilder sb = new StringBuilder(prototype); sb.Replace("$YEAR", buildTime.ToString("yyyy")); sb.Replace("$MONTH", buildTime.ToString("MM")); sb.Replace("$DAY", buildTime.ToString("dd")); sb.Replace("$TIME", buildTime.ToString("hhmmss")); string archName = arch.name; if (buildPlatform.variants != null && buildPlatform.variants.Length > 0) { archName += "(" + buildPlatform.variantKey + ")"; } sb.Replace("$RELEASE_TYPE", SanitizeFolderName(releaseType.typeName)); sb.Replace("$PLATFORM", SanitizeFolderName(buildPlatform.platformName)); sb.Replace("$ARCHITECTURE", SanitizeFolderName(archName)); sb.Replace("$DISTRIBUTION", SanitizeFolderName(dist != null ? dist.distributionName : BuildConstantsGenerator.NONE)); sb.Replace("$VERSION", SanitizeFolderName(BuildSettings.productParameters.lastGeneratedVersion)); sb.Replace("$BUILD", BuildSettings.productParameters.buildCounter.ToString()); sb.Replace("$PRODUCT_NAME", SanitizeFolderName(releaseType.productName)); return(sb.ToString()); }
private static bool BuildPlayer(string notification, BuildReleaseType releaseType, BuildPlatform platform, BuildArchitecture architecture, BuildDistribution distribution, DateTime buildTime, BuildOptions options, string configKey) { bool success = true; // Get build options. if (releaseType.developmentBuild) { options |= BuildOptions.Development; } if (releaseType.allowDebugging) { options |= BuildOptions.AllowDebugging; } // Generate build path. string buildPath = GenerateBuildPath(BuildSettings.basicSettings.buildPath, releaseType, platform, architecture, distribution, buildTime); string exeName = string.Format(platform.binaryNameFormat, SanitizeFileName(releaseType.productName)); // Set defines. string defines = GenerateDefaultDefines(releaseType, platform, architecture, distribution); PlayerSettings.SetScriptingDefineSymbolsForGroup(platform.targetGroup, defines); // Pre-build actions. PerformPreBuild(releaseType, platform, architecture, distribution, buildTime, ref options, configKey, buildPath); // Generate BuildConstants. BuildConstantsGenerator.Generate(buildTime, BuildSettings.productParameters.lastGeneratedVersion, releaseType, platform, architecture, distribution); // Refresh scene list to make sure nothing has been deleted or moved. releaseType.sceneList.Refresh(); // Report build starting. BuildNotificationList.instance.AddNotification(new BuildNotification( BuildNotification.Category.Notification, notification, configKey, true, null)); // Build player. FileUtil.DeleteFileOrDirectory(buildPath); string error = BuildPipeline.BuildPlayer(releaseType.sceneList.GetSceneList(), Path.Combine(buildPath, exeName), architecture.target, options); if (!string.IsNullOrEmpty(error)) { success = false; BuildNotificationList.instance.AddNotification(new BuildNotification( BuildNotification.Category.Error, "Build Failed:", configKey.ToString() + "\n" + error, true, null)); } // Post-build actions. PerformPostBuild(releaseType, platform, architecture, distribution, buildTime, ref options, configKey, buildPath); return(success); }
private static bool BuildPlayer(string notification, BuildReleaseType releaseType, BuildPlatform platform, BuildArchitecture architecture, BuildDistribution distribution, DateTime buildTime, BuildOptions options, string configKey) { bool success = true; // Get build options.获取生成选项。 if (releaseType.developmentBuild) { options |= BuildOptions.Development; } if (releaseType.allowDebugging) { options |= BuildOptions.AllowDebugging; } if (releaseType.enableHeadlessMode) { options |= BuildOptions.EnableHeadlessMode; } // Generate build path.生成生成路径。 string buildPath = GenerateBuildPath(BuildSettings.basicSettings.buildPath, releaseType, platform, architecture, distribution, buildTime); string binName = string.Format(architecture.binaryNameFormat, SanitizeFileName(releaseType.productName)); // Save current user defines, and then set target defines.保存当前用户定义,然后设置目标定义。 string preBuildDefines = PlayerSettings.GetScriptingDefineSymbolsForGroup(platform.targetGroup); string buildDefines = GenerateDefaultDefines(releaseType, platform, architecture, distribution); buildDefines = MergeDefines(preBuildDefines, buildDefines); PlayerSettings.SetScriptingDefineSymbolsForGroup(platform.targetGroup, buildDefines); //Debug.Log("Build Defines: " + buildDefines); // Save current player settings, and then set target settings.保存当前播放机设置,然后设置目标设置。 string preBuildCompanyName = PlayerSettings.companyName; string preBuildProductName = PlayerSettings.productName; PlayerSettings.companyName = releaseType.companyName; PlayerSettings.productName = releaseType.productName; // Set bundle info.设置捆绑信息。 // Unfortunately, there's not a good way to do this pre-5.6 that doesn't break building w/ batch mode.不幸的是,在5.6之前没有一个好的方法可以不破坏构建w/batch模式。 #if UNITY_5_6_OR_NEWER string preBuildBundleIdentifier = PlayerSettings.GetApplicationIdentifier(platform.targetGroup); PlayerSettings.SetApplicationIdentifier(platform.targetGroup, releaseType.bundleIndentifier); #endif // Apply build variant.应用生成变量。 platform.ApplyVariant(); // Pre-build actions.预构建操作。 PerformPreBuild(releaseType, platform, architecture, distribution, buildTime, ref options, configKey, buildPath); // Generate BuildConstants.生成生成常量。 BuildConstantsGenerator.Generate(buildTime, BuildSettings.productParameters.lastGeneratedVersion, releaseType, platform, architecture, distribution); // Refresh scene list to make sure nothing has been deleted or moved.刷新场景列表以确保未删除或移动任何内容。 releaseType.sceneList.Refresh(); // Report build starting.发布生成开始。 BuildNotificationList.instance.AddNotification(new BuildNotification( BuildNotification.Category.Notification, notification, configKey, true, null)); // Build player. FileUtil.DeleteFileOrDirectory(buildPath); string error = ""; #if UNITY_2018_1_OR_NEWER // string[] levels = BuildInfomation.levels; ///// Debug.Log("这里才开始生成"); //string parth = BuildInfomation. Pathlevels+"/Test.exe"; // string[]levels = new string[] { "Assets/Scenes/2.unity" }; string[] levels = BuildInfomation.levels; ///\ Debug.Log("这里才开始生成"); string parth = BuildInfomation.Pathlevels; Debug.Log(parth); // Debug.Log("这里才开始生成---"+ BuildInfomation.levels[0].ToString()+"---"+ parth); // Debug.Log(releaseType.sceneList.GetSceneFileList() + " --AAA-- " + Path.Combine(buildPath, binName) ); // UnityEditor.Build.Reporting.BuildReport buildReport = BuildPipeline.BuildPlayer(levels, @"C:/Users/YNHol/Desktop/00000000000000/Scenes3/Test.exe", BuildTarget.StandaloneWindows, BuildOptions.None); UnityEditor.Build.Reporting.BuildReport buildReport = BuildPipeline.BuildPlayer(levels, parth, BuildTarget.WebGL, BuildOptions.None); // UnityEditor.Build.Reporting.BuildReport buildReport = BuildPipeline.BuildPlayer(releaseType.sceneList.GetSceneFileList(), Path.Combine(buildPath, binName), architecture.target, options); // Debug.Log(levels[0].ToString() + "__生产___" + parth); ; foreach (var item in releaseType.sceneList.GetSceneFileList()) { Debug.Log(item); } // Debug.Log("这里生成开始完毕"); if (buildReport.summary.result == UnityEditor.Build.Reporting.BuildResult.Failed) { error = buildReport.summary.totalErrors + " occurred."; } #else error = BuildPipeline.BuildPlayer(releaseType.sceneList.GetSceneFileList(), Path.Combine(buildPath, binName), architecture.target, options); #endif if (!string.IsNullOrEmpty(error)) { success = false; BuildNotificationList.instance.AddNotification(new BuildNotification( BuildNotification.Category.Error, "Build Failed:", configKey.ToString() + "\n" + error, true, null)); } // Post-build actions. PerformPostBuild(releaseType, platform, architecture, distribution, buildTime, ref options, configKey, buildPath); // Restore pre-build settings. PlayerSettings.SetScriptingDefineSymbolsForGroup(platform.targetGroup, preBuildDefines); PlayerSettings.companyName = preBuildCompanyName; PlayerSettings.productName = preBuildProductName; #if UNITY_5_6_OR_NEWER PlayerSettings.SetApplicationIdentifier(platform.targetGroup, preBuildBundleIdentifier); #endif /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Build_Over_Num++; Debug.Log("这里是北京时间:" + System.DateTime.Now + " 完成了___ " + Build_Over_Num + " ___个"); if (Build_Over_Num < File.ReadAllLines(Application.dataPath + "/Pathlevels.txt", Encoding.Default).Length) { BuildInfomation.Pathlevels = File.ReadAllLines(Application.dataPath + "/Pathlevels.txt", Encoding.Default)[Build_Over_Num]; BuildInfomation.levels = new string[] { File.ReadAllLines(Application.dataPath + "/levels.txt", Encoding.Default)[Build_Over_Num] }; BuildProject.BuildAll(); } else { Debug.Log("这里是北京时间:" + System.DateTime.Now + " 全部完成! " + Build_Over_Num + "个"); Build_Over_Num = 0; } return(success); }
public static void Generate( DateTime buildTime, string currentVersion = "", BuildReleaseType currentReleaseType = null, BuildPlatform currentBuildPlatform = null, BuildArchitecture currentBuildArchitecture = null, BuildDistribution currentBuildDistribution = null) { // Find the BuildConstants file. string filePath = FindFile(); if (string.IsNullOrEmpty(filePath)) { return; } // Cache any current values if needed. string versionString = string.IsNullOrEmpty(currentVersion) ? BuildConstants.version.ToString() : currentVersion; string releaseTypeString = currentReleaseType == null?BuildConstants.releaseType.ToString() : SanitizeString(currentReleaseType.typeName); string platformString = currentBuildPlatform == null?BuildConstants.platform.ToString() : SanitizeString(currentBuildPlatform.platformName); string archString = currentBuildArchitecture == null?BuildConstants.architecture.ToString() : SanitizeString(currentBuildArchitecture.name); string distributionString = string.Empty; if (currentBuildDistribution == null) { if (currentReleaseType == null) { // No new parameter specified, so use the old value. distributionString = BuildConstants.architecture.ToString(); } else { // There are new parameters but no distribution. Should be intentional, so distribution is NONE. distributionString = NONE; } } else { distributionString = SanitizeString(currentBuildDistribution.distributionName); } // Delete any existing version. if (File.Exists(filePath)) { File.Delete(filePath); } // Create a buffer that we'll use to check for any duplicated names. List <string> enumBuffer = new List <string>(); using (StreamWriter writer = new StreamWriter(filePath)) { // Start of file and class. writer.WriteLine("// This file is auto-generated. Do not modify or move this file."); writer.WriteLine(); writer.WriteLine("public static class BuildConstants"); writer.WriteLine("{"); // Write ReleaseType enum. writer.WriteLine(" public enum ReleaseType"); writer.WriteLine(" {"); writer.WriteLine(" {0},", NONE); enumBuffer.Add(NONE); foreach (BuildReleaseType releaseType in BuildSettings.releaseTypeList.releaseTypes) { string addedString = SanitizeString(releaseType.typeName); if (!enumBuffer.Contains(addedString)) { enumBuffer.Add(addedString); writer.WriteLine(" {0},", addedString); } } writer.WriteLine(" }"); writer.WriteLine(); // Validate ReleaseType string. if (!enumBuffer.Contains(releaseTypeString)) { releaseTypeString = NONE; } // Write Platform enum. enumBuffer.Clear(); writer.WriteLine(" public enum Platform"); writer.WriteLine(" {"); writer.WriteLine(" {0},", NONE); enumBuffer.Add(NONE); foreach (BuildPlatform platform in BuildSettings.platformList.platforms) { string addedString = SanitizeString(platform.platformName); if (platform.enabled && !enumBuffer.Contains(addedString)) { enumBuffer.Add(addedString); writer.WriteLine(" {0},", addedString); } } writer.WriteLine(" }"); writer.WriteLine(); // Validate Platform string. if (!enumBuffer.Contains(platformString)) { platformString = NONE; } // Write Architecture enum. enumBuffer.Clear(); writer.WriteLine(" public enum Architecture"); writer.WriteLine(" {"); writer.WriteLine(" {0},", NONE); enumBuffer.Add(NONE); foreach (BuildPlatform platform in BuildSettings.platformList.platforms) { if (platform.enabled) { foreach (BuildArchitecture arch in platform.architectures) { string addedString = SanitizeString(arch.name); if (arch.enabled && !enumBuffer.Contains(addedString)) { enumBuffer.Add(addedString); writer.WriteLine(" {0},", addedString); } } } } writer.WriteLine(" }"); writer.WriteLine(); // Validate Architecture string. if (!enumBuffer.Contains(archString)) { archString = NONE; } // Write Distribution enum. enumBuffer.Clear(); writer.WriteLine(" public enum Distribution"); writer.WriteLine(" {"); writer.WriteLine(" {0},", NONE); enumBuffer.Add(NONE); foreach (BuildPlatform platform in BuildSettings.platformList.platforms) { if (platform.enabled) { foreach (BuildDistribution dist in platform.distributionList.distributions) { string addedString = SanitizeString(dist.distributionName); if (dist.enabled && !enumBuffer.Contains(addedString)) { enumBuffer.Add(addedString); writer.WriteLine(" {0},", addedString); } } } } writer.WriteLine(" }"); writer.WriteLine(); // Validate Distribution string. if (!enumBuffer.Contains(distributionString)) { distributionString = NONE; } // Write current values. writer.WriteLine(" public static readonly System.DateTime buildDate = new System.DateTime({0});", buildTime.Ticks); writer.WriteLine(" public const string version = \"{0}\";", versionString); writer.WriteLine(" public const ReleaseType releaseType = ReleaseType.{0};", releaseTypeString); writer.WriteLine(" public const Platform platform = Platform.{0};", platformString); writer.WriteLine(" public const Architecture architecture = Architecture.{0};", archString); writer.WriteLine(" public const Distribution distribution = Distribution.{0};", distributionString); // End of class. writer.WriteLine("}"); writer.WriteLine(); } // Refresh AssetDatabse so that changes take effect. AssetDatabase.Refresh(); }
public override void PerBuildExecute(BuildReleaseType releaseType, BuildPlatform platform, BuildArchitecture architecture, BuildDistribution distribution, DateTime buildTime, ref BuildOptions options, string configKey, string buildPath) { PackagesToRemove.ForEach(id => HandleRequest(Client.Remove(id), id)); PackagesToAdd.ForEach(id => HandleRequest(Client.Add(id), id)); }
public override void PerBuildExecute(BuildReleaseType releaseType, BuildPlatform platform, BuildArchitecture architecture, BuildDistribution distribution, DateTime buildTime, ref BuildOptions options, string configKey, string buildPath) { // Set preloaded assets Object[] preloadedAssets = PlayerSettings.GetPreloadedAssets(); List <Object> preloadedAssetsList = PreservePreloadedAssets ? preloadedAssets.ToList() : new List <Object>(); preloadedAssetsList.AddRange(PreloadedAssets); PlayerSettings.SetPreloadedAssets(preloadedAssetsList.ToArray()); }
public override void PerBuildExecute(BuildReleaseType releaseType, BuildPlatform platform, BuildArchitecture architecture, BuildDistribution distribution, System.DateTime buildTime, ref BuildOptions options, string configKey, string buildPath) { string resolvedInputPath = BuildProject.ResolvePath(packageFolderPath.Replace("$BUILDPATH", buildPath), releaseType, platform, architecture, distribution, buildTime); string resolvedOutputPath = BuildProject.ResolvePath(outputPath.Replace("$BUILDPATH", buildPath), releaseType, platform, architecture, distribution, buildTime); if (Directory.Exists(Path.GetDirectoryName(resolvedOutputPath)) == false) { Directory.CreateDirectory(Path.GetDirectoryName(resolvedOutputPath)); } Export(resolvedInputPath, resolvedOutputPath); }
public override void PerBuildExecute(BuildReleaseType releaseType, BuildPlatform platform, BuildArchitecture architecture, BuildDistribution distribution, System.DateTime buildTime, ref UnityEditor.BuildOptions options, string configKey, string buildPath) { string resolvedOutputPath = Path.Combine(outputPath.Replace("$BUILDPATH", buildPath), outputFileName); resolvedOutputPath = BuildProject.ResolvePath(resolvedOutputPath, releaseType, platform, architecture, distribution, buildTime); string resolvedInputPath = inputPath.Replace("$BUILDPATH", buildPath); resolvedInputPath = BuildProject.ResolvePath(resolvedInputPath, releaseType, platform, architecture, distribution, buildTime); if (!resolvedOutputPath.EndsWith(".zip")) { resolvedOutputPath += ".zip"; } PerformZip(Path.GetFullPath(resolvedInputPath), Path.GetFullPath(resolvedOutputPath)); }
public override void PerBuildExecute(BuildReleaseType releaseType, BuildPlatform platform, BuildArchitecture architecture, BuildDistribution distribution, DateTime buildTime, ref BuildOptions options, string configKey, string buildPath) { XRGeneralSettings generalSettings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(platform.targetGroup); XRManagerSettings settingsManager = generalSettings.Manager; generalSettings.InitManagerOnStart = InitializeXROnStartup; settingsManager.loaders = XRPlugins; }
public static string GenerateBuildPath(string prototype, BuildReleaseType releaseType, BuildPlatform buildPlatform, BuildArchitecture arch, BuildDistribution dist, DateTime buildTime) { string resolvedProto = ResolvePath(prototype, releaseType, buildPlatform, arch, dist, buildTime); string buildPath = Path.Combine(BuildSettings.basicSettings.baseBuildFolder, resolvedProto); buildPath = Path.GetFullPath(buildPath).TrimEnd('\\').TrimEnd('/'); return(buildPath); }
public override void PerBuildExecute(BuildReleaseType releaseType, BuildPlatform platform, BuildArchitecture architecture, BuildDistribution distribution, System.DateTime buildTime, ref BuildOptions options, string configKey, string buildPath) { // Get valid SDKs for platform string[] validSDKs = PlayerSettings.GetAvailableVirtualRealitySDKs(platform.targetGroup); // Build list of valid SDKs to set List <string> sdks = new List <string>(); foreach (SDK sdk in Sdks) { string sdkName = sdkNames[sdk]; if (Array.IndexOf(validSDKs, sdkName) != -1) { sdks.Add(sdkName); } } // Update player settings PlayerSettings.SetVirtualRealitySupported(platform.targetGroup, VRSupported); PlayerSettings.SetVirtualRealitySDKs(platform.targetGroup, sdks.ToArray()); PlayerSettings.stereoRenderingPath = StereoRenderingMode; #if SUPPORTS_OCULUS_V2_SIGNING PlayerSettings.VROculus.v2Signing = OculusV2Signing; #endif if (platform.targetGroup == BuildTargetGroup.Android) { PlayerSettings.Android.ARCoreEnabled = ARCoreSupported; } }
private static bool BuildPlayer(string notification, BuildReleaseType releaseType, BuildPlatform platform, BuildArchitecture architecture, BuildDistribution distribution, DateTime buildTime, BuildOptions options, string configKey) { bool success = true; // Get build options. if (releaseType.developmentBuild) { options |= BuildOptions.Development; } if (releaseType.allowDebugging) { options |= BuildOptions.AllowDebugging; } if (releaseType.enableHeadlessMode) { options |= BuildOptions.EnableHeadlessMode; } // Generate build path. string buildPath = GenerateBuildPath(BuildSettings.basicSettings.buildPath, releaseType, platform, architecture, distribution, buildTime); string exeName = string.Format(platform.binaryNameFormat, SanitizeFileName(releaseType.productName)); // Save current user defines, and then set target defines. string preBuildDefines = PlayerSettings.GetScriptingDefineSymbolsForGroup(platform.targetGroup); string buildDefines = GenerateDefaultDefines(releaseType, platform, architecture, distribution); buildDefines = MergeDefines(preBuildDefines, buildDefines); PlayerSettings.SetScriptingDefineSymbolsForGroup(platform.targetGroup, buildDefines); //Debug.Log("Build Defines: " + buildDefines); // Set bundle info. // Unfortunately, there's not a good way to do this pre-5.6 that doesn't break building w/ batch mode. #if UNITY_5_6_OR_NEWER PlayerSettings.SetApplicationIdentifier(platform.targetGroup, releaseType.bundleIndentifier); #endif // Set product name. PlayerSettings.companyName = releaseType.companyName; PlayerSettings.productName = releaseType.productName; // Apply build variant. platform.ApplyVariant(); // Pre-build actions. PerformPreBuild(releaseType, platform, architecture, distribution, buildTime, ref options, configKey, buildPath); // Generate BuildConstants. BuildConstantsGenerator.Generate(buildTime, BuildSettings.productParameters.lastGeneratedVersion, releaseType, platform, architecture, distribution); // Refresh scene list to make sure nothing has been deleted or moved. releaseType.sceneList.Refresh(); // Report build starting. BuildNotificationList.instance.AddNotification(new BuildNotification( BuildNotification.Category.Notification, notification, configKey, true, null)); // Build player. FileUtil.DeleteFileOrDirectory(buildPath); string error = ""; #if UNITY_2018_1_OR_NEWER UnityEditor.Build.Reporting.BuildReport buildReport = BuildPipeline.BuildPlayer(releaseType.sceneList.GetSceneFileList(), Path.Combine(buildPath, exeName), architecture.target, options); if (buildReport.summary.result == UnityEditor.Build.Reporting.BuildResult.Failed) { error = buildReport.summary.totalErrors + " occurred."; } #else error = BuildPipeline.BuildPlayer(releaseType.sceneList.GetSceneFileList(), Path.Combine(buildPath, exeName), architecture.target, options); #endif if (!string.IsNullOrEmpty(error)) { success = false; BuildNotificationList.instance.AddNotification(new BuildNotification( BuildNotification.Category.Error, "Build Failed:", configKey.ToString() + "\n" + error, true, null)); } // Post-build actions. PerformPostBuild(releaseType, platform, architecture, distribution, buildTime, ref options, configKey, buildPath); // Restore pre-build settings. PlayerSettings.SetScriptingDefineSymbolsForGroup(platform.targetGroup, preBuildDefines); return(success); }
public bool ParseKeychain(string keychain, out BuildReleaseType releaseType, out BuildPlatform platform, out BuildArchitecture architecture, out BuildDistribution distribution) { bool success = false; string[] keys = keychain.Split('/'); int keyCount = keys.Length; int targetKey = 0; releaseType = null; platform = null; architecture = null; distribution = null; // Parse release type. if (keyCount > targetKey) { for (int i = 0; i < BuildSettings.releaseTypeList.releaseTypes.Length; i++) { BuildReleaseType rt = BuildSettings.releaseTypeList.releaseTypes[i]; if (keys[targetKey] == rt.typeName) { releaseType = rt; break; } } } if (releaseType == null) { return(false); } // Parse platform. if (keyCount > ++targetKey) { for (int i = 0; i < BuildSettings.platformList.platforms.Length; i++) { BuildPlatform p = BuildSettings.platformList.platforms[i]; if (keys[targetKey] == p.platformName) { platform = p; break; } } } if (platform == null) { return(false); } // Parse architecture. if (platform.architectures.Length == 1) { // Only one architecture, so it won't even appear in dictionary. Just get it directly. architecture = platform.architectures[0]; success = true; } else if (keyCount > ++targetKey) { for (int i = 0; i < platform.architectures.Length; i++) { BuildArchitecture arch = platform.architectures[i]; if (keys[targetKey] == arch.name) { architecture = arch; success = true; break; } } } if (architecture == null) { return(false); } // TODO: Parse variants. // Parse distribution. if (keyCount > ++targetKey) { success = false; for (int i = 0; i < platform.distributionList.distributions.Length; i++) { BuildDistribution dist = platform.distributionList.distributions[i]; if (keys[targetKey] == dist.distributionName) { distribution = dist; success = true; break; } } } return(success); }