/// <summary> /// Create and save a Build Report. This is meant to be used for users who have a /// custom build script, or is automating a project build command from the command line. /// /// The Editor log needs to have build data for this to work, /// so only call this after <see cref="UnityEditor.BuildPipeline.BuildPlayer"/>. /// </summary> /// /// <remarks> /// <para>If your custom build scripts override the project's build settings, /// this overload allows you to explicitly specify the list of scenes, the build /// location, and the build target yourself.</para> /// /// <para>But if your build scripts didn't override the project's build settings, /// you can instead use <see cref="CreateReport(string)"/>.</para> /// </remarks> /// /// <param name="scenes">Which scenes were included in the build. Can be set to null /// so that BuildReportTool will just use UnityEditor.EditorBuildSettings.scenes instead. /// If you specified your own list of scenes to build, you should pass them here.</param> /// /// <param name="buildLocation">Where the build is saved to. Can be set to null so that /// BuildReportTool will just use UnityEditor.EditorUserBuildSettings.GetBuildLocation() /// instead. If you specified your own build location, you should pass it here.</param> /// /// <param name="buildTarget">Type of build platform being made. You can just pass /// UnityEditor.EditorUserBuildSettings.activeBuildTarget if you didn't explicitly /// set this. If you specified your own build target, you should pass it here.</param> /// /// <param name="customEditorLogPath">If your Unity Editor log file is not in the /// default path, specify it here. Otherwise, leave this null so that BuildReportTool /// will just use the default location of the Editor.log file.</param> /// /// <returns>The full path and filename of the created Build Report XML file, /// or null if no Build Report was created.</returns> public static string CreateReport(string[] scenes, string buildLocation, BuildTarget buildTarget, string customEditorLogPath = null) { BuildReportTool.Util.BuildTargetOfLastBuild = buildTarget; var editorLogPathToUse = !string.IsNullOrEmpty(customEditorLogPath) ? customEditorLogPath : BuildReportTool.Util.UsedEditorLogPath; if (!DoesEditorLogHaveBuildInfo(editorLogPathToUse)) { if (BuildReportTool.Util.IsDefaultEditorLogPathOverridden) { Debug.LogWarning(string.Format(NO_BUILD_INFO_OVERRIDDEN_LOG_WARNING, editorLogPathToUse, BuildReportTool.Options.FoundPathForSavedOptions)); } else if (CheckIfUnityHasNoLogArgument()) { Debug.LogWarning(NO_BUILD_INFO_NO_LOG_WARNING); } else { Debug.LogWarning(NO_BUILD_INFO_WARNING); } return(null); } var timeGot = System.DateTime.Now; _timeReportGenerationStarted = new System.TimeSpan(timeGot.Ticks); _lastPathToBuiltProject = buildLocation; Init(ref _lastKnownBuildInfo, scenes, timeGot); if (BuildReportTool.Options.CalculateAssetDependencies) { if (_lastKnownAssetDependencies == null) { _lastKnownAssetDependencies = new BuildReportTool.AssetDependencies(); } _lastKnownAssetDependencies.TimeGot = timeGot; } _lastEditorLogPath = editorLogPathToUse; if (BuildReportTool.Options.IncludeUnusedPrefabsInReportCreation) { RefreshListOfAllPrefabsUsedInAllScenesIncludedInBuild(); } else { ClearListOfAllPrefabsUsedInAllScenes(); } CommitAdditionalInfoToCache(); CreateBuildReport(_lastKnownBuildInfo); var savedFilePath = OnFinishedGetValues(_lastKnownBuildInfo, _lastKnownAssetDependencies); return(savedFilePath); }
/// <summary> /// Create and save a Build Report. This is meant to be used for users who have a /// custom build script, or is automating a project build command from the command line. /// /// The Editor log needs to have build data for this to work, /// so only call this after <see cref="UnityEditor.BuildPipeline.BuildPlayer"/>. /// </summary> /// /// <remarks> /// <para>If your custom build scripts override the project's build settings, /// this overload allows you to explicitly specify the list of scenes, the build /// location, and the build target yourself.</para> /// /// <para>But if your build scripts didn't override the project's build settings, /// you can instead use <see cref="CreateReport(string)"/>.</para> /// </remarks> /// /// <param name="scenes">Which scenes were included in the build. Can be set to null /// so that BuildReportTool will just use UnityEditor.EditorBuildSettings.scenes instead. /// If you specified your own list of scenes when building, you should pass them here.</param> /// /// <param name="buildLocation">Absolute path where the build was saved to. Can be set to null so that /// BuildReportTool will just use Unity's <see cref="UnityEditor.EditorUserBuildSettings.GetBuildLocation"/> /// instead. If you specified your own build location, you should set it here. /// /// You can specify only the path to the build folder, but if there are multiple builds /// in that folder, it is best to specify the path to the build file itself /// (e.g. exe file for Windows Standalone, apk file for Android, etc.).</param> /// /// <param name="buildTarget">Type of build platform being made. You can just pass /// UnityEditor.EditorUserBuildSettings.activeBuildTarget if you didn't explicitly /// set this. If you specified your own build target, you should pass it here.</param> /// /// <param name="customEditorLogPath">If your Unity Editor log file is not in the /// default path, specify it here. Otherwise, leave this null so that BuildReportTool /// will just use the default location of the Editor.log file.</param> /// /// <returns>The full path and filename of the created Build Report XML file, /// or null if no Build Report was created.</returns> public static string CreateReport(string[] scenes, string buildLocation, BuildTarget buildTarget, string customEditorLogPath = null) { BuildReportTool.Util.BuildTargetOfLastBuild = buildTarget; var editorLogPathToUse = !string.IsNullOrEmpty(customEditorLogPath) ? customEditorLogPath : BuildReportTool.Util.UsedEditorLogPath; if (!DoesEditorLogHaveBuildInfo(editorLogPathToUse)) { if (BuildReportTool.Util.IsDefaultEditorLogPathOverridden) { Debug.LogWarning(string.Format(NO_BUILD_INFO_OVERRIDDEN_LOG_WARNING, editorLogPathToUse, BuildReportTool.Options.FoundPathForSavedOptions)); } else if (CheckIfUnityHasNoLogArgument()) { Debug.LogWarning(NO_BUILD_INFO_NO_LOG_WARNING); } else { Debug.LogWarning(NO_BUILD_INFO_WARNING); } return(null); } var timeNow = System.DateTime.Now; _lastPathToBuiltProject = buildLocation; Init(true, ref _lastKnownBuildInfo, scenes); _lastKnownBuildInfo.TimeGot = timeNow; _lastKnownBuildInfo.TimeGotReadable = timeNow.ToString(TIME_OF_BUILD_FORMAT); System.DateTime timeBuildStarted; if (BuildReportTool.Util.HasBuildTime()) { timeBuildStarted = BuildReportTool.Util.LoadBuildTime(); } else { timeBuildStarted = timeNow; } if (BuildReportTool.Options.CalculateAssetDependencies) { if (_lastKnownAssetDependencies == null) { _lastKnownAssetDependencies = new BuildReportTool.AssetDependencies(); } _lastKnownAssetDependencies.TimeGot = timeBuildStarted; } if (BuildReportTool.Options.CollectTextureImportSettings) { if (_lastKnownTextureData == null) { _lastKnownTextureData = new BuildReportTool.TextureData(); } _lastKnownTextureData.TimeGot = timeBuildStarted; } _lastEditorLogPath = editorLogPathToUse; if (BuildReportTool.Options.IncludeUnusedPrefabsInReportCreation) { RefreshListOfAllPrefabsUsedInAllScenesIncludedInBuild(); } else { ClearListOfAllPrefabsUsedInAllScenes(); } CommitAdditionalInfoToCache(); CreateBuildReport(_lastKnownBuildInfo); var savedFilePath = OnFinishedGetValues(_lastKnownBuildInfo, _lastKnownAssetDependencies, _lastKnownTextureData); return(savedFilePath); }